From 928950e3c442fd48cfd5da846d52cfad315a1f3a Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 11 Jun 2021 17:14:23 -0500 Subject: [PATCH] Minor improvements --- bot.js | 14 +++--- package-lock.json | 116 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 96 insertions(+), 34 deletions(-) diff --git a/bot.js b/bot.js index 084d8b3..1ccf728 100644 --- a/bot.js +++ b/bot.js @@ -3,7 +3,7 @@ const Discord = require('discord.js'); const MongoClient = require('mongodb').MongoClient; 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"], }); const fetch = require(`node-fetch`); @@ -325,6 +325,7 @@ async function addEmoji(message) { return; } } + async function aboutBot(message) { const uptimeDays = client.uptime / 86400000; let serverCount; @@ -957,6 +958,7 @@ async function usersWith(message) { async function aboutServer(message) { await message.guild.members.fetch(); + await message.guild.roles.fetch(); 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 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("Channels", `Total: ${message.guild.channels.cache.size} ‖ Text: ${textChannelCount} • Voice: ${voiceChannelCount} • Categories: ${categoryChannelCount}`) .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("User Statuses", `🟦 • ${numOnline} online\n\n🟧 • ${numAway} away\n\n⬛ • ${numOffline} offline\n\n🟥 • ${numDND} DND`) .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) .addField('Author', message.author ? message.author.tag : "Message not cached") .addField('Message', message.content ? message.content : "Message not cached") - .addField('Channel', message.channel ? message.channel : "Message not cached") - .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) + .addField('Channel', message.channel ? "<#" + message.channel.id + ">" : "Message not cached") + .setThumbnail(message.author ? message.author.displayAvatarURL({ dynamic: true, size: 1024 }) : client.defaultAvatarURL) .setFooter("ID: " + message.id) .setTimestamp() .setColor('e7778b'); @@ -1225,7 +1227,7 @@ client.on('messageReactionAdd', (messageReaction, user) => { .addField("Link", `[Click here!](${message.url})`, true) .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .addField(`# of 😎 Reactions`, `${numEmoji}`, true) - .addField("Channel", message.channel, true) + .addField("Channel", "<#" + message.channel.id + ">", true) .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setFooter("Message ID: " + message.id) .setColor("00c5ff") @@ -1346,7 +1348,7 @@ client.on('messageReactionRemove', async (messageReaction, user) => { .addField("Link", `[Click here!](${message.url})`, true) .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .addField(`# of 😎 Reactions`, `${numEmoji}`, true) - .addField("Channel", message.channel, true) + .addField("Channel", "<#" + message.channel + ">", true) .setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 1024 })) .setFooter("Message ID: " + message.id) .setColor("00c5ff") diff --git a/package-lock.json b/package-lock.json index 1913d1c..4babc04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,15 @@ "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": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -53,6 +62,19 @@ "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": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -440,21 +462,33 @@ "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": { - "version": "12.5.0", - "resolved": "git+ssh://git@github.com/discordjs/discord.js.git#a6079bc9ce40ecbb4adace033dbf201897b5459f", + "version": "13.0.0-dev", + "resolved": "git+ssh://git@github.com/discordjs/discord.js.git#1d57754d4654c5c95aa14afc13f8abe335314767", "license": "Apache-2.0", "dependencies": { "@discordjs/collection": "^0.1.6", "@discordjs/form-data": "^3.0.1", + "@sapphire/async-queue": "^1.1.2", + "@types/ws": "^7.4.4", "abort-controller": "^3.0.0", + "discord-api-types": "^0.18.1", "node-fetch": "^2.6.1", - "prism-media": "^1.2.2", + "prism-media": "^1.2.9", "tweetnacl": "^1.0.3", - "ws": "^7.3.1" + "ws": "^7.4.6" }, "engines": { - "node": ">=14.0.0" + "node": ">=14.0.0", + "npm": ">=7.0.0" } }, "node_modules/dot-prop": { @@ -812,19 +846,19 @@ "optional": true }, "node_modules/mime-db": { - "version": "1.47.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", - "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", + "version": "1.48.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", + "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.30", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", - "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", + "version": "2.1.31", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", + "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", "dependencies": { - "mime-db": "1.47.0" + "mime-db": "1.48.0" }, "engines": { "node": ">= 0.6" @@ -1450,9 +1484,9 @@ } }, "node_modules/ws": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz", - "integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==", + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", "engines": { "node": ">=8.3.0" }, @@ -1494,6 +1528,11 @@ "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": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -1507,6 +1546,19 @@ "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": { "version": "1.1.1", "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", "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": { - "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", "requires": { "@discordjs/collection": "^0.1.6", "@discordjs/form-data": "^3.0.1", + "@sapphire/async-queue": "^1.1.2", + "@types/ws": "^7.4.4", "abort-controller": "^3.0.0", + "discord-api-types": "^0.18.1", "node-fetch": "^2.6.1", - "prism-media": "^1.2.2", + "prism-media": "^1.2.9", "tweetnacl": "^1.0.3", - "ws": "^7.3.1" + "ws": "^7.4.6" } }, "dot-prop": { @@ -2100,16 +2160,16 @@ "optional": true }, "mime-db": { - "version": "1.47.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", - "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==" + "version": "1.48.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", + "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==" }, "mime-types": { - "version": "2.1.30", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", - "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", + "version": "2.1.31", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", + "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", "requires": { - "mime-db": "1.47.0" + "mime-db": "1.48.0" } }, "mimic-response": { @@ -2600,9 +2660,9 @@ } }, "ws": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz", - "integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==", + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", "requires": {} }, "xdg-basedir": {