Browse Source

Fix formatting for code

master
Abheek Dhawan 4 years ago
parent
commit
ee1b1474b0
  1. 53
      index.js

53
index.js

@ -10,7 +10,7 @@ const CONNECTION_URL = "localhost:27017";
const prefix = '$';
MongoClient.connect("mongodb://" + CONNECTION_URL, { useNewUrlParser: true }, (error, client) => {
if(error) {
if (error) {
throw error;
}
database = client.db(DATABASE_NAME);
@ -21,7 +21,7 @@ MongoClient.connect("mongodb://" + CONNECTION_URL, { useNewUrlParser: true }, (e
client.on("guildCreate", async guild => {
let awesomeModCatID, botLogID, roleReqID;
collection.insertOne({ guild_id: guild.id }, (error, result) => {
if(error) {
if (error) {
console.error;
}
});
@ -47,7 +47,7 @@ client.on("guildCreate", async guild => {
}]
}).then(channel => {
// Add the ID of the "#bot-logs" channel to the database
collection.updateOne({ guild_id: guild.id }, { $set: { "bot_logs_id": `${channel.id}` }});
collection.updateOne({ guild_id: guild.id }, { $set: { "bot_logs_id": `${channel.id}` } });
});
// Create "#role-requests" text channel to have people request roles
guild.channels.create('role-requests', {
@ -60,7 +60,7 @@ client.on("guildCreate", async guild => {
}]
}).then(channel => {
// Add the ID of the "#bot-logs" channel to the database
collection.updateOne({ guild_id: guild.id }, { $set: { "role_requests_id": `${channel.id}` }});
collection.updateOne({ guild_id: guild.id }, { $set: { "role_requests_id": `${channel.id}` } });
// Add slowmode
channel.setRateLimitPerUser(60);
});
@ -69,8 +69,9 @@ client.on("guildCreate", async guild => {
});
client.on("guildDelete", async guild => {
// If the bot is removed from a guild or the guild is deleted, the bot deletes the old data
collection.deleteOne({ "guild_id": `${guild.id}` }, (error, result) => {
if(error) {
if (error) {
console.error;
}
});
@ -186,8 +187,8 @@ async function roleRequest(message) {
return;
}
collection.findOne({ guild_id: message.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: message.guild.id }, (error, result) => {
if (error) {
console.error;
}
roleChannel = result.role_requests_id;
@ -237,7 +238,7 @@ async function bulkDelete(message) {
return;
}
await message.channel.messages.fetch( { limit: amount + 1 } ).then(messages => {
await message.channel.messages.fetch({ limit: amount + 1 }).then(messages => {
message.channel.bulkDelete(messages).catch(console.error);
}).catch(console.error);
}
@ -266,8 +267,8 @@ client.on('messageDelete', message => {
.setTimestamp()
.setColor('e7778b');
collection.findOne({ guild_id: message.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: message.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -287,8 +288,8 @@ client.on('messageDeleteBulk', messages => {
.setTimestamp()
.setColor('e7778b');
collection.findOne({ guild_id: messagesChannel.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: messagesChannel.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -311,8 +312,8 @@ client.on('messageUpdate', (originalMessage, editedMessage) => {
.setFooter("ID: " + editedMessage.id)
.setTimestamp()
.setColor('c9ff00');
collection.findOne({ guild_id: message.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: message.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -341,8 +342,8 @@ client.on('channelCreate', channel => {
.setFooter("ID: " + channelID)
.setTimestamp()
.setColor('00aaff');
collection.findOne({ guild_id: channel.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: channel.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -365,8 +366,8 @@ client.on('messageReactionAdd', (messageReaction, user) => {
.setFooter("Message ID: " + messageReaction.message.id)
.setTimestamp()
.setColor('00aaff');
collection.findOne({ guild_id: messageReaction.message.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -388,8 +389,8 @@ client.on('messageReactionRemove', (messageReaction, user) => {
.setFooter("Message ID: " + messageReaction.message.id)
.setTimestamp()
.setColor('e7778b');
collection.findOne({ guild_id: messageReaction.message.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -408,8 +409,8 @@ client.on('roleCreate', role => {
.setFooter("Role ID: " + role.id)
.setTimestamp()
.setColor('00aaff');
collection.findOne({ guild_id: role.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: role.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -428,8 +429,8 @@ client.on('roleDelete', role => {
.setFooter("Role ID: " + role.id)
.setTimestamp()
.setColor('e7778b');
collection.findOne({ guild_id: role.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: role.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;
@ -448,8 +449,8 @@ client.on('roleUpdate', (oldRole, newRole) => {
.setFooter("Role ID: " + newRole.id)
.setTimestamp()
.setColor('c9ff00');
collection.findOne({ guild_id: newRole.guild.id}, (error, result) => {
if(error) {
collection.findOne({ guild_id: newRole.guild.id }, (error, result) => {
if (error) {
console.error;
}
botLogsChannel = result.bot_logs_id;

Loading…
Cancel
Save