From c7b87dc4bf4f1cf506f60f830bac365f2540a4dd Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sun, 11 Dec 2022 17:22:31 +1100 Subject: [PATCH 1/4] update EmbedBuilder --- bot/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/index.js b/bot/index.js index 340a4fc..80c1bbb 100644 --- a/bot/index.js +++ b/bot/index.js @@ -21,7 +21,7 @@ class WoomyClient extends Discord.Client { // Essential modules this.logger = Logger; - this.MessageEmbed = Discord.MessageEmbed; + this.EmbedBuilder = Discord.EmbedBuilder; this.db = new Database(this); this.functions = new Functions(this); this.commandLoader = new CommandLoader(this); From f812359b422ab2ec15cdebe8fcfc853e95c06e59 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sun, 11 Dec 2022 17:22:57 +1100 Subject: [PATCH 2/4] oops forgot to change the cooldown warn from msg --- bot/event_modules/interactionCreate/interactionHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/event_modules/interactionCreate/interactionHandler.js b/bot/event_modules/interactionCreate/interactionHandler.js index 50dc4ab..4b3afe6 100644 --- a/bot/event_modules/interactionCreate/interactionHandler.js +++ b/bot/event_modules/interactionCreate/interactionHandler.js @@ -33,7 +33,7 @@ module.exports = class { const cooldown = command.cooldown / 1000; const timePassed = Math.floor((currentTime - timestamp) / 1000); return interaction.reply( - `${client.config.emojis.wait} ${message.author.mention}, you need to wait ${cooldown - timePassed} seconds before using this command again.` + `${client.config.emojis.wait} <@${interaction.user.id}>, you need to wait ${cooldown - timePassed} seconds before using this command again.` ); } else { client.cooldowns.get(command.name).set(interaction.user.id, new Date()); @@ -42,6 +42,7 @@ module.exports = class { }, client.commands.get(command.name).cooldown); } + // Try to execute the command, if it fails return error stack and inform the user try { command.run(client, interaction, data); client.logger.command(`Ran ${command.name}`); From c33e02e06dbe8b3d0b5b0e9192a8b9793f6f98d8 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sun, 11 Dec 2022 17:23:07 +1100 Subject: [PATCH 3/4] ping command actually pings --- bot/commands/Bot/ping.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/commands/Bot/ping.js b/bot/commands/Bot/ping.js index 9bce46a..94b1446 100644 --- a/bot/commands/Bot/ping.js +++ b/bot/commands/Bot/ping.js @@ -1,4 +1,5 @@ const Command = require("../../base/Command.js"); +const replies = require('../../assets/replies.json'); module.exports = class Ping extends Command { constructor (name, category) { @@ -8,7 +9,8 @@ module.exports = class Ping extends Command { this.category = category } - run (client, interaction, data) { //eslint-disable-line no-unused-vars - return interaction.reply('Pong! Did I do this right?'); + async run (client, interaction, data) { //eslint-disable-line no-unused-vars + const msg = await interaction.reply({ content: replies.ping.random(), fetchReply: true }); + interaction.editReply(`${msg.content} Roundtrip: \`${msg.createdTimestamp - interaction.createdTimestamp}ms\` Heartbeat: \`${client.ws.ping}ms\``); } }; \ No newline at end of file From c3490af9d026cd47e2c465355f80cfbae3ce67f5 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sun, 11 Dec 2022 17:23:21 +1100 Subject: [PATCH 4/4] avatar command --- bot/commands/Utility/avatar.js | 33 ++++++++++++++++++++ bot/commands/Utility/avatar.js.du | 52 ------------------------------- 2 files changed, 33 insertions(+), 52 deletions(-) create mode 100644 bot/commands/Utility/avatar.js delete mode 100644 bot/commands/Utility/avatar.js.du diff --git a/bot/commands/Utility/avatar.js b/bot/commands/Utility/avatar.js new file mode 100644 index 0000000..6bc5a35 --- /dev/null +++ b/bot/commands/Utility/avatar.js @@ -0,0 +1,33 @@ +const Command = require("../../base/Command.js"); + +module.exports = class Avatar extends Command { + constructor (name, category) { + super (name, category) + this.name = name, + this.description = 'View a full-sized version of someone\'s avatar.', + this.options = [ + { + type: 6, + name: "user", + description: "The user to get the avatar of." + }, + ], + this.usage = "/avatar [user]" + this.friendlyOptions = "`user` - The user to get the avatar of (optional)", + this.category = category + } + + async run (client, interaction, data) { //eslint-disable-line no-unused-vars + const target = await interaction.options.getUser('user') ?? interaction.user; + const user = await client.users.fetch(target.id, {force: true}) + const member = await interaction.guild.members.fetch(target.id, {force: true}) + + const embed = new client.EmbedBuilder() + .setTitle(user.username + '#' + user.discriminator + "'s avatar") + .setColor(user.hexAccentColor ?? member.displayHexColor) + .setDescription(`[Global avatar](${user.avatarURL({extension: "png", "size": 4096})})`) + .setImage(member.displayAvatarURL({extension: "png", "size": 4096})); + + await interaction.reply({embeds: [embed]}); + } +}; \ No newline at end of file diff --git a/bot/commands/Utility/avatar.js.du b/bot/commands/Utility/avatar.js.du deleted file mode 100644 index 1190003..0000000 --- a/bot/commands/Utility/avatar.js.du +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = class { - constructor (name, category) { - this.name = name, - this.category = category, - this.enabled = true, - this.devOnly = false, - this.aliases = ['pfp'], - this.userPerms = [], - this.botPerms = [], - this.cooldown = 2000, - this.help = { - description: 'View a full-sized version of someone\'s avatar.', - arguments: '', - details: '', - examples: 'avatar\navatar @May\navatar emily' - }; - } - - async run (client, message, args, data) { //eslint-disable-line no-unused-vars - - let member = message.member; - - if (args[0]) { - if (message.mentions.length > 0) { - member = await message.guild.members.fetch(message.mentions[0].id) - } else { - member = await client.functions.validateUserID(message.guild, args[0]); - - if (!member) { - member = await message.guild.searchMembers(args.join(' '), 2); - - if (member.length === 0) return message.channel.send( - `${client.config.emojis.userError} No users found. Check for mispellings, or ping the user instead.` - ); - - if (member.length > 1) return message.channel.send( - `${client.config.emojis.userError} Found more than one user, try refining your search or pinging the user instead.` - ); - - member = member[0]; - } - } - } - - const embed = new client.MessageEmbed() - .setTitle(member.user.username + '#' + member.user.discriminator) - .setColor(client.functions.embedColor(message.guild, member)) - .setImage(member.user.avatarURL); - - message.channel.send({ embeds: [embed] }); - } -}; \ No newline at end of file