Browse Source

Merge branch 'master' of /srv/git/bots/awesomemod

master
Abheek Dhawan 4 years ago
parent
commit
d8f9aff6b0
  1. 129
      bot.js

129
bot.js

@ -43,36 +43,6 @@ client.on("ready", () => {
}); });
client.on("message", async message => { client.on("message", async message => {
const filter = reaction => {
return reaction.emoji.name === '😎';
};
const collector = message.createReactionCollector(filter);
collector.on('collect', (reaction, user) => {
if (reaction.count === 1) {
const kulboardEmbed = new Discord.MessageEmbed()
.setTitle("Very kül message")
.setURL(message.url)
.setAuthor(message.author ? message.author.tag : "Unknown: click on the link to find out", message.author ? message.author.avatarURL() : client.user.defaultAvatarURL)
.addField("Message", message.content)
.addField("Channel", message.channel)
.setFooter("Message ID: " + message.id)
.setColor("00c5ff")
.setTimestamp();
collection.findOne({ guild_id: message.guild.id }, (error, result) => {
if (error) {
console.error;
}
if (result.kulboard_id) {
kulboardChannel = result.kulboard_id;
if (message.guild.channels.cache.get(kulboardChannel)) {
message.guild.channels.cache.get(kulboardChannel).send(kulboardEmbed).catch(console.error);
}
}
});
}
});
if (!message.content.startsWith(prefix) || message.author.bot) { if (!message.content.startsWith(prefix) || message.author.bot) {
return;j return;j
} }
@ -687,28 +657,17 @@ async function bulkDelete(message) {
}).catch(console.error); }).catch(console.error);
} }
client.on('messageDelete', message => { client.on('messageDelete', msg => {
let messageContent = message.content; msg.channel.messages.fetch(msg.id)
let messageAvatar; .then(message => {
const messageID = message.id;
let messageAuthor;
if (message.author) {
messageAuthor = message.author.tag;
messageAvatar = message.author.avatarURL();
} else {
messageAuthor = "Message was not cached";
messageAvatar = client.user.defaultAvatarURL;
}
if (!messageContent) {
messageContent = "[NONE]";
}
const deleteEmbed = new Discord.MessageEmbed() const deleteEmbed = new Discord.MessageEmbed()
.setTitle('Message Deleted') .setTitle('Message Deleted')
.setAuthor(message.author.tag, message.author.avatarURL())
.setURL(message.url) .setURL(message.url)
.addField('Author', messageAuthor) .addField('Author', message.author.tag)
.addField('Message', messageContent) .addField('Message', message.content)
.setThumbnail(messageAvatar) .setThumbnail(message.author.avatarURL())
.setFooter("ID: " + messageID) .setFooter("ID: " + message.id)
.setTimestamp() .setTimestamp()
.setColor('e7778b'); .setColor('e7778b');
@ -723,6 +682,7 @@ client.on('messageDelete', message => {
} }
} }
}); });
});
}); });
client.on('messageDeleteBulk', messages => { client.on('messageDeleteBulk', messages => {
@ -807,49 +767,63 @@ client.on('channelCreate', channel => {
}); });
client.on('messageReactionAdd', (messageReaction, user) => { client.on('messageReactionAdd', (messageReaction, user) => {
const userTag = user.tag; messageReaction.message.channel.messages.fetch(messageReaction.message.id)
.then(message => {
const emoji = messageReaction.emoji.name; const emoji = messageReaction.emoji.name;
const numEmoji = messageReaction.count; const numEmoji = message.reactions.cache.get(emoji).count;
let messageContent = messageReaction.message.content;
if (!messageContent) {
messageContent = "[NONE]";
}
let channelCategory;
const messageReactionAddEmbed = new Discord.MessageEmbed() const messageReactionAddEmbed = new Discord.MessageEmbed()
.setTitle("Reaction Added") .setTitle("Reaction Added")
.setURL(messageReaction.message.url) .setURL(message.url)
.addField("Message", messageContent) .addField("Message", message.content)
.addField("Reactions", `${userTag} reacted with ${emoji}, along with ${numEmoji - 1} other people in ${messageReaction.message.channel}.`) .addField("Reactions", `\`${user.tag}\` reacted with \`${emoji}\`, along with ${numEmoji - 1} other people in ${messageReaction.message.channel}.`)
.setFooter("Message ID: " + messageReaction.message.id) .setFooter("Message ID: " + messageReaction.message.id)
.setThumbnail(message.author.avatarURL())
.setTimestamp() .setTimestamp()
.setColor('00aaff'); .setColor('00aaff');
const kulboardEmbed = new Discord.MessageEmbed()
.setTitle("Very kül message")
.setURL(message.url)
.setAuthor(message.author, message.author.avatarURL())
.addField("Message", message.content)
.addField("Channel", message.channel)
.setThumbnail(message.author.avatarURL())
.setFooter("Message ID: " + message.id)
.setColor("00c5ff")
.setTimestamp();
collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => { collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => {
if (error) { if (error) {
console.error; console.error;
} }
if (result.bot_logs_id) { if (result.bot_logs_id) {
botLogsChannel = result.bot_logs_id; botLogsChannel = result.bot_logs_id;
if (messageReaction.message.guild.channels.cache.get(botLogsChannel)) { if (message.guild.channels.cache.get(botLogsChannel)) {
messageReaction.message.guild.channels.cache.get(botLogsChannel).send(messageReactionAddEmbed).catch(console.error); message.guild.channels.cache.get(botLogsChannel).send(messageReactionAddEmbed).catch(console.error);
}
if (result.kulboard_id) {
kulboardChannel = result.kulboard_id;
if (message.guild.channels.cache.get(kulboardChannel)) {
message.guild.channels.cache.get(kulboardChannel).send(kulboardEmbed).catch(console.error);
} }
} }
}
});
}); });
}); });
client.on('messageReactionRemove', (messageReaction, user) => { client.on('messageReactionRemove', (messageReaction, user) => {
const userTag = user.tag; messageReaction.message.channel.messages.fetch(messageReaction.message.id)
.then(message => {
const emoji = messageReaction.emoji.name; const emoji = messageReaction.emoji.name;
let messageContent = messageReaction.message.content;
if (!messageContent) {
messageContent = "[NONE]";
}
let channelCategory;
const messageReactionRemoveEmbed = new Discord.MessageEmbed() const messageReactionRemoveEmbed = new Discord.MessageEmbed()
.setTitle("Reaction Removed") .setTitle("Reaction Removed")
.setURL(messageReaction.message.url) .setURL(message.url)
.addField("Message", messageContent) .addField("Message", message.content)
.addField("Reactions", `${userTag} removed their reaction ${emoji} in ${messageReaction.message.channel}.`) .addField("Reactions", `\`${user.tag}\` removed their reaction \`${emoji}\` in ${messageReaction.message.channel}.`)
.setFooter("Message ID: " + messageReaction.message.id) .setFooter("Message ID: " + messageReaction.message.id)
.setThumbnail(message.author.avatarURL())
.setTimestamp() .setTimestamp()
.setColor('e7778b'); .setColor('e7778b');
collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => { collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => {
@ -863,6 +837,7 @@ client.on('messageReactionRemove', (messageReaction, user) => {
} }
} }
}); });
});
}); });
client.on('roleCreate', role => { client.on('roleCreate', role => {
@ -910,8 +885,8 @@ client.on('roleDelete', role => {
}); });
client.on('roleUpdate', (oldRole, newRole) => { client.on('roleUpdate', (oldRole, newRole) => {
/*const removedPerms = oldRole.permissions.filter(perm => !newRole.hasPermission(perm)); const removedPerms = oldRole.permissions.toArray().filter(perm => !newRole.permissions.has(perm));
const addedPerms = newRole.permissions.filter(perm => !oldRole.hasPermission(perm));*/ const addedPerms = newRole.permissions.toArray().filter(perm => !oldRole.permissions.has(perm));
const roleUpdateEmbed = new Discord.MessageEmbed() const roleUpdateEmbed = new Discord.MessageEmbed()
.setTitle("Role Updated") .setTitle("Role Updated")
.addField("Name", `${oldRole.name} >> ${newRole.name}`) .addField("Name", `${oldRole.name} >> ${newRole.name}`)
@ -920,12 +895,12 @@ client.on('roleUpdate', (oldRole, newRole) => {
.setFooter("Role ID: " + newRole.id) .setFooter("Role ID: " + newRole.id)
.setTimestamp() .setTimestamp()
.setColor('c9ff00'); .setColor('c9ff00');
/*if (removedPerms.array().length > 0) { if (removedPerms.length > 0) {
roleUpdateEmbed.addField("Permissions Removed", removedPerms.map(p => `${p}`).join(' • ')); roleUpdateEmbed.addField("Permissions Removed", removedPerms.map(p => `\`${p}\``.toLowerCase()).join(' • '));
}
if (addedPerms.length > 0) {
roleUpdateEmbed.addField("Permissions Added", addedPerms.map(p => `\`${p}\``.toLowerCase()).join(' • '));
} }
if (addedPerms.array().length > 0) {
roleUpdateEmbed.addField("Permissions Added", addedPerms.map(p => `${p}`).join(' • '));
}*/
collection.findOne({ guild_id: newRole.guild.id }, (error, result) => { collection.findOne({ guild_id: newRole.guild.id }, (error, result) => {
if (error) { if (error) {
console.error; console.error;

Loading…
Cancel
Save