Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions commands/create-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ module.exports = {
Utils.errAndMsg(message.channel, 'Invalid arguments.');
} else {
try {
let name = args[0];
let color = args[1]
if (args.length > 2) {
name = args.slice(1, -1).reduce( (str, val) => str + ' ' + val, args[0]);
color = args[args.length - 1]
}
const role = await guild.createRole({
name: args[0],
color: args[1],

Comment thread
iFallUpHill marked this conversation as resolved.
Outdated
name: name,
color: color,
});
Utils.logAndMsg(message.channel, `Created new role with name ${role.name} and color ${role.color}`);
Utils.logAndMsg(message.channel, `Created new role with name \`${role.name}\` and color \`${role.color}\``);
} catch (err) {
console.error(err);
message.channel.send(`Couldn't create role ${args[0]} because: ${err}`);
Expand Down
7 changes: 6 additions & 1 deletion commands/delete-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ module.exports = {
Utils.errAndMsg(message.channel, 'Invalid arguments.');
} else {
try {
const deleted = await guild.roles.find(role => role.name === args[0]).delete();
let name = args[0];
if (args.length > 1) {
name = args.slice(1).reduce( (str, val) => str + ' ' + val, args[0]);
}

const deleted = await guild.roles.find(role => role.name === name).delete();
Utils.logAndMsg(message.channel, `Deleted role ${deleted.name}`);
} catch (err) {
console.error(err);
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"prefix": "kimbap ",
"ignorePrefixes": [ "pg" ]
}
}
4 changes: 2 additions & 2 deletions events/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async (client, message) => {
} else {
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
console.log(args, command);
// console.log(args, command);

let commandToRun = null;

Expand All @@ -29,4 +29,4 @@ module.exports = async (client, message) => {
}
}
return;
};
};
80 changes: 40 additions & 40 deletions utils/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ const Attachment = require('discord.js').Attachment;
const UrlValidator = require('./UrlValidator.js');

archiveMedia = (message) => {
console.log(message);
const guild = message.guild;
if (!guild) return;
// :wconsole.log(message);
const guild = message.guild;
if (!guild) return;

const embeds = message.embeds;
const attachments = message.attachments;
if (embeds) {
embeds.forEach((embed) => {
const ytMatch = UrlValidator.matchYTUrl(embed.url);
const igMatch = UrlValidator.matchIGUrl(embed.url);
const spMatch = UrlValidator.matchSpotifyUrl(embed.url);
const vlMatch = UrlValidator.matchVLiveUrl(embed.url);
if (ytMatch) {
const ytChannel = guild.channels.find(ch => ch.name === 'youtube-links');
if (ytChannel) ytChannel.send(ytMatch[0]);
} else if (igMatch) {
const igChannel = guild.channels.find(ch => ch.name === 'instagram-links');
if (igChannel) igChannel.send(igMatch[0]);
} else if (spMatch) {
const spChannel = guild.channels.find(ch => ch.name === 'spotify-links');
if (spChannel) spChannel.send(spMatch[0]);
} else if (vlMatch) {
const vliveChannel = guild.channels.find(ch => ch.name === 'vlive-links');
if (vliveChannel) vliveChannel.send(vlMatch[0]);
} else if (embed.type === 'link') {
const linkChannel = guild.channels.find(ch => ch.name === 'general-links');
if (linkChannel) linkChannel.send(embed.url);
} else if (embed.type !== 'rich') {
const mediaChannel = guild.channels.find(ch => ch.name === 'media');
if (mediaChannel) mediaChannel.send(embed.url);
}
});
}
if (attachments) {
attachments.forEach((attachment) => {
const mediaChannel = guild.channels.find(ch => ch.name === 'attachments');
if (mediaChannel) mediaChannel.send(new Attachment(attachment.url));
});
}
const embeds = message.embeds;
const attachments = message.attachments;
if (embeds) {
embeds.forEach((embed) => {
const ytMatch = UrlValidator.matchYTUrl(embed.url);
const igMatch = UrlValidator.matchIGUrl(embed.url);
const spMatch = UrlValidator.matchSpotifyUrl(embed.url);
const vlMatch = UrlValidator.matchVLiveUrl(embed.url);
if (ytMatch) {
const ytChannel = guild.channels.find(ch => ch.name === 'youtube-links');
if (ytChannel) ytChannel.send(ytMatch[0]);
} else if (igMatch) {
const igChannel = guild.channels.find(ch => ch.name === 'instagram-links');
if (igChannel) igChannel.send(igMatch[0]);
} else if (spMatch) {
const spChannel = guild.channels.find(ch => ch.name === 'spotify-links');
if (spChannel) spChannel.send(spMatch[0]);
} else if (vlMatch) {
const vliveChannel = guild.channels.find(ch => ch.name === 'vlive-links');
if (vliveChannel) vliveChannel.send(vlMatch[0]);
} else if (embed.type === 'link') {
const linkChannel = guild.channels.find(ch => ch.name === 'general-links');
if (linkChannel) linkChannel.send(embed.url);
} else if (embed.type !== 'rich') {
const mediaChannel = guild.channels.find(ch => ch.name === 'media');
if (mediaChannel) mediaChannel.send(embed.url);
}
});
}
if (attachments) {
attachments.forEach((attachment) => {
const mediaChannel = guild.channels.find(ch => ch.name === 'attachments');
if (mediaChannel) mediaChannel.send(new Attachment(attachment.url));
});
}
};

module.exports = {
archiveMedia,
};
archiveMedia,
};
16 changes: 8 additions & 8 deletions utils/Utils.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const errorPhrases = require('../assets/errorPhrases.json');

logAndMsg = (channel, msg) => {
console.log(msg);
channel.send(msg);
// console.log(msg);
channel.send(msg);
};
getRandomIndex = (arr) => Math.floor(Math.random() * arr.length);
errAndMsg = (channel, err) => {
console.error(err);
channel.send(`${errorPhrases[getRandomIndex(errorPhrases)]} ${err}`);
console.error(err);
channel.send(`${errorPhrases[getRandomIndex(errorPhrases)]} ${err}`);
};


module.exports = {
logAndMsg,
getRandomIndex,
errAndMsg,
};
logAndMsg,
getRandomIndex,
errAndMsg,
};