Browse Source

Minor improvements

master
Abheek Dhawan 4 years ago
parent
commit
928950e3c4
  1. 14
      bot.js
  2. 116
      package-lock.json

14
bot.js

@ -3,7 +3,7 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const MongoClient = require('mongodb').MongoClient; const MongoClient = require('mongodb').MongoClient;
const client = new Discord.Client({ const client = new Discord.Client({
intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS"], intents: ["GUILD_PRESENCES", "GUILD_MEMBERS", "GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS"],
partials: ["MESSAGE", "CHANNEL", "REACTION"], partials: ["MESSAGE", "CHANNEL", "REACTION"],
}); });
const fetch = require(`node-fetch`); const fetch = require(`node-fetch`);
@ -325,6 +325,7 @@ async function addEmoji(message) {
return; return;
} }
} }
async function aboutBot(message) { async function aboutBot(message) {
const uptimeDays = client.uptime / 86400000; const uptimeDays = client.uptime / 86400000;
let serverCount; let serverCount;
@ -957,6 +958,7 @@ async function usersWith(message) {
async function aboutServer(message) { async function aboutServer(message) {
await message.guild.members.fetch(); await message.guild.members.fetch();
await message.guild.roles.fetch();
const textChannelCount = message.guild.channels.cache.filter(c => c.type === 'text').size; const textChannelCount = message.guild.channels.cache.filter(c => c.type === 'text').size;
const voiceChannelCount = message.guild.channels.cache.filter(c => c.type === 'voice').size; const voiceChannelCount = message.guild.channels.cache.filter(c => c.type === 'voice').size;
const categoryChannelCount = message.guild.channels.cache.filter(c => c.type === 'category').size; const categoryChannelCount = message.guild.channels.cache.filter(c => c.type === 'category').size;
@ -974,7 +976,7 @@ async function aboutServer(message) {
.addField("Verification Level", message.guild.verificationLevel) .addField("Verification Level", message.guild.verificationLevel)
.addField("Channels", `Total: ${message.guild.channels.cache.size} ‖ Text: ${textChannelCount} • Voice: ${voiceChannelCount} • Categories: ${categoryChannelCount}`) .addField("Channels", `Total: ${message.guild.channels.cache.size} ‖ Text: ${textChannelCount} • Voice: ${voiceChannelCount} • Categories: ${categoryChannelCount}`)
.addField("Members", `Total: ${numHumans + numBots} ‖ Human: ${numHumans} • Bot: ${numBots}`) .addField("Members", `Total: ${numHumans + numBots} ‖ Human: ${numHumans} • Bot: ${numBots}`)
.addField("Roles", numRoles) .addField("Roles", `${numRoles}`)
.addField("Created", `${new Date(message.guild.createdTimestamp).toLocaleString("en-US", {timeZoneName: "short"})}`) .addField("Created", `${new Date(message.guild.createdTimestamp).toLocaleString("en-US", {timeZoneName: "short"})}`)
.addField("User Statuses", `🟦 • ${numOnline} online\n\n🟧 • ${numAway} away\n\n⬛ • ${numOffline} offline\n\n🟥 • ${numDND} DND`) .addField("User Statuses", `🟦 • ${numOnline} online\n\n🟧 • ${numAway} away\n\n⬛ • ${numOffline} offline\n\n🟥 • ${numDND} DND`)
.setThumbnail(message.guild.iconURL({ dynamic: true, size: 1024 })) .setThumbnail(message.guild.iconURL({ dynamic: true, size: 1024 }))
@ -1072,8 +1074,8 @@ client.on('messageDelete', message => {
.setAuthor(message.author ? message.author.tag : "Unknown", message.author ? message.author.displayAvatarURL({ dynamic: true, size: 1024 }) : client.defaultAvatarURL) .setAuthor(message.author ? message.author.tag : "Unknown", message.author ? message.author.displayAvatarURL({ dynamic: true, size: 1024 }) : client.defaultAvatarURL)
.addField('Author', message.author ? message.author.tag : "Message not cached") .addField('Author', message.author ? message.author.tag : "Message not cached")
.addField('Message', message.content ? message.content : "Message not cached") .addField('Message', message.content ? message.content : "Message not cached")
.addField('Channel', message.channel ? message.channel : "Message not cached") .addField('Channel', message.channel ? "<#" + message.channel.id + ">" : "Message not cached")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setThumbnail(message.author ? message.author.displayAvatarURL({ dynamic: true, size: 1024 }) : client.defaultAvatarURL)
.setFooter("ID: " + message.id) .setFooter("ID: " + message.id)
.setTimestamp() .setTimestamp()
.setColor('e7778b'); .setColor('e7778b');
@ -1225,7 +1227,7 @@ client.on('messageReactionAdd', (messageReaction, user) => {
.addField("Link", `[Click here!](${message.url})`, true) .addField("Link", `[Click here!](${message.url})`, true)
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.addField(`# of 😎 Reactions`, `${numEmoji}`, true) .addField(`# of 😎 Reactions`, `${numEmoji}`, true)
.addField("Channel", message.channel, true) .addField("Channel", "<#" + message.channel.id + ">", true)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.setFooter("Message ID: " + message.id) .setFooter("Message ID: " + message.id)
.setColor("00c5ff") .setColor("00c5ff")
@ -1346,7 +1348,7 @@ client.on('messageReactionRemove', async (messageReaction, user) => {
.addField("Link", `[Click here!](${message.url})`, true) .addField("Link", `[Click here!](${message.url})`, true)
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.addField(`# of 😎 Reactions`, `${numEmoji}`, true) .addField(`# of 😎 Reactions`, `${numEmoji}`, true)
.addField("Channel", message.channel, true) .addField("Channel", "<#" + message.channel + ">", true)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 }))
.setFooter("Message ID: " + message.id) .setFooter("Message ID: " + message.id)
.setColor("00c5ff") .setColor("00c5ff")

116
package-lock.json

@ -34,6 +34,15 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/@sapphire/async-queue": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.2.tgz",
"integrity": "sha512-NkR7AzC9uyb++tMIZgG4X0ci8JM1rnvNmKbLwY42RgotRV8JGUntZ7ZpR7MN7p5zPlVdKo/YmOqcCCsBJ6LNuw==",
"engines": {
"node": ">=14",
"npm": ">=6"
}
},
"node_modules/@sindresorhus/is": { "node_modules/@sindresorhus/is": {
"version": "0.14.0", "version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
@ -53,6 +62,19 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/@types/node": {
"version": "15.12.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.1.tgz",
"integrity": "sha512-zyxJM8I1c9q5sRMtVF+zdd13Jt6RU4r4qfhTd7lQubyThvLfx6yYekWSQjGCGV2Tkecgxnlpl/DNlb6Hg+dmEw=="
},
"node_modules/@types/ws": {
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.4.tgz",
"integrity": "sha512-d/7W23JAXPodQNbOZNXvl2K+bqAQrCMwlh/nuQsPSQk6Fq0opHoPrUw43aHsvSbIiQPr8Of2hkFbnz1XBFVyZQ==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/abbrev": { "node_modules/abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -440,21 +462,33 @@
"node": ">=0.10" "node": ">=0.10"
} }
}, },
"node_modules/discord-api-types": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.18.1.tgz",
"integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg==",
"engines": {
"node": ">=12"
}
},
"node_modules/discord.js": { "node_modules/discord.js": {
"version": "12.5.0", "version": "13.0.0-dev",
"resolved": "git+ssh://git@github.com/discordjs/discord.js.git#a6079bc9ce40ecbb4adace033dbf201897b5459f", "resolved": "git+ssh://git@github.com/discordjs/discord.js.git#1d57754d4654c5c95aa14afc13f8abe335314767",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@discordjs/collection": "^0.1.6", "@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1", "@discordjs/form-data": "^3.0.1",
"@sapphire/async-queue": "^1.1.2",
"@types/ws": "^7.4.4",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"discord-api-types": "^0.18.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"prism-media": "^1.2.2", "prism-media": "^1.2.9",
"tweetnacl": "^1.0.3", "tweetnacl": "^1.0.3",
"ws": "^7.3.1" "ws": "^7.4.6"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0",
"npm": ">=7.0.0"
} }
}, },
"node_modules/dot-prop": { "node_modules/dot-prop": {
@ -812,19 +846,19 @@
"optional": true "optional": true
}, },
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.47.0", "version": "1.48.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz",
"integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/mime-types": { "node_modules/mime-types": {
"version": "2.1.30", "version": "2.1.31",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz",
"integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==",
"dependencies": { "dependencies": {
"mime-db": "1.47.0" "mime-db": "1.48.0"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@ -1450,9 +1484,9 @@
} }
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "7.4.5", "version": "7.4.6",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
"integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"engines": { "engines": {
"node": ">=8.3.0" "node": ">=8.3.0"
}, },
@ -1494,6 +1528,11 @@
"mime-types": "^2.1.12" "mime-types": "^2.1.12"
} }
}, },
"@sapphire/async-queue": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.2.tgz",
"integrity": "sha512-NkR7AzC9uyb++tMIZgG4X0ci8JM1rnvNmKbLwY42RgotRV8JGUntZ7ZpR7MN7p5zPlVdKo/YmOqcCCsBJ6LNuw=="
},
"@sindresorhus/is": { "@sindresorhus/is": {
"version": "0.14.0", "version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
@ -1507,6 +1546,19 @@
"defer-to-connect": "^1.0.1" "defer-to-connect": "^1.0.1"
} }
}, },
"@types/node": {
"version": "15.12.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.1.tgz",
"integrity": "sha512-zyxJM8I1c9q5sRMtVF+zdd13Jt6RU4r4qfhTd7lQubyThvLfx6yYekWSQjGCGV2Tkecgxnlpl/DNlb6Hg+dmEw=="
},
"@types/ws": {
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.4.tgz",
"integrity": "sha512-d/7W23JAXPodQNbOZNXvl2K+bqAQrCMwlh/nuQsPSQk6Fq0opHoPrUw43aHsvSbIiQPr8Of2hkFbnz1XBFVyZQ==",
"requires": {
"@types/node": "*"
}
},
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -1814,17 +1866,25 @@
"resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz",
"integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ=="
}, },
"discord-api-types": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.18.1.tgz",
"integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg=="
},
"discord.js": { "discord.js": {
"version": "git+ssh://git@github.com/discordjs/discord.js.git#a6079bc9ce40ecbb4adace033dbf201897b5459f", "version": "git+ssh://git@github.com/discordjs/discord.js.git#1d57754d4654c5c95aa14afc13f8abe335314767",
"from": "discord.js@github:discordjs/discord.js", "from": "discord.js@github:discordjs/discord.js",
"requires": { "requires": {
"@discordjs/collection": "^0.1.6", "@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1", "@discordjs/form-data": "^3.0.1",
"@sapphire/async-queue": "^1.1.2",
"@types/ws": "^7.4.4",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"discord-api-types": "^0.18.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"prism-media": "^1.2.2", "prism-media": "^1.2.9",
"tweetnacl": "^1.0.3", "tweetnacl": "^1.0.3",
"ws": "^7.3.1" "ws": "^7.4.6"
} }
}, },
"dot-prop": { "dot-prop": {
@ -2100,16 +2160,16 @@
"optional": true "optional": true
}, },
"mime-db": { "mime-db": {
"version": "1.47.0", "version": "1.48.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz",
"integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==" "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.30", "version": "2.1.31",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz",
"integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==",
"requires": { "requires": {
"mime-db": "1.47.0" "mime-db": "1.48.0"
} }
}, },
"mimic-response": { "mimic-response": {
@ -2600,9 +2660,9 @@
} }
}, },
"ws": { "ws": {
"version": "7.4.5", "version": "7.4.6",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
"integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"requires": {} "requires": {}
}, },
"xdg-basedir": { "xdg-basedir": {

Loading…
Cancel
Save