From 085546e0cf6fc57d7381d1ec2c679fe48eaf132c Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 26 Apr 2024 23:47:58 -0400 Subject: [PATCH] Make owner commands cleaner --- commands/util/banner.js | 29 --------------------- commands/util/command-last-run-export.js | 4 +-- commands/util/command-leaderboard-export.js | 4 +-- commands/util/generate-commands.js | 4 +-- commands/util/generate-credit.js | 4 +-- commands/util/generate-process-env.js | 4 +-- commands/util/ip.js | 4 +-- 7 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 commands/util/banner.js diff --git a/commands/util/banner.js b/commands/util/banner.js deleted file mode 100644 index 1f3d4439..00000000 --- a/commands/util/banner.js +++ /dev/null @@ -1,29 +0,0 @@ -const Command = require('../../framework/Command'); -const { DataResolver, Routes } = require('discord.js'); - -module.exports = class BannerCommand extends Command { - constructor(client) { - super(client, { - name: 'banner', - group: 'util', - memberName: 'banner', - description: 'Sets the bot\'s banner.', - details: 'Only the bot owner(s) may use this command.', - ownerOnly: true, - guarded: true, - args: [ - { - key: 'image', - type: 'image' - } - ] - }); - } - - async run(msg, { image }) { - await this.client.rest.patch(Routes.user(), { - body: { banner: await DataResolver.resolveImage(image) } - }); - return msg.say('Set the banner.'); - } -}; diff --git a/commands/util/command-last-run-export.js b/commands/util/command-last-run-export.js index ef424b39..3c6ddf94 100644 --- a/commands/util/command-last-run-export.js +++ b/commands/util/command-last-run-export.js @@ -30,7 +30,7 @@ module.exports = class CommandLastRunExportCommand extends Command { async run(msg) { const result = this.client.exportLastRun(); - await msg.direct({ files: [{ attachment: result, name: 'command-last-run.json' }] }); - return msg.say('📬 Sent `command-last-run.json` to your DMs!'); + if (msg.guild) await msg.say('📬 Sent `command-last-run.json` to your DMs!'); + return msg.direct({ files: [{ attachment: result, name: 'command-last-run.json' }] }); } }; diff --git a/commands/util/command-leaderboard-export.js b/commands/util/command-leaderboard-export.js index 1f60f595..d8857c71 100644 --- a/commands/util/command-leaderboard-export.js +++ b/commands/util/command-leaderboard-export.js @@ -24,7 +24,7 @@ module.exports = class CommandLeaderboardExportCommand extends Command { async run(msg) { const result = this.client.exportCommandLeaderboard(); - await msg.direct({ files: [{ attachment: result, name: 'command-leaderboard.json' }] }); - return msg.say('📬 Sent `command-leaderboard.json` to your DMs!'); + if (msg.guild) await msg.say('📬 Sent `command-leaderboard.json` to your DMs!'); + return msg.direct({ files: [{ attachment: result, name: 'command-leaderboard.json' }] }); } }; diff --git a/commands/util/generate-commands.js b/commands/util/generate-commands.js index 3f02dbbd..f277f080 100644 --- a/commands/util/generate-commands.js +++ b/commands/util/generate-commands.js @@ -29,7 +29,7 @@ module.exports = class GenerateCommandsCommand extends Command { }) .filter(cmds => cmds); const text = `Total: ${this.client.registry.commands.size}\n${list.join('\n')}`; - await msg.direct({ files: [{ attachment: Buffer.from(text), name: 'commands.txt' }] }); - return msg.say('📬 Sent `commands.txt` to your DMs!'); + if (msg.guild) await msg.say('📬 Sent `commands.txt` to your DMs!'); + return msg.direct({ files: [{ attachment: Buffer.from(text), name: 'commands.txt' }] }); } }; diff --git a/commands/util/generate-credit.js b/commands/util/generate-credit.js index 0a306c4b..9ee26ce4 100644 --- a/commands/util/generate-credit.js +++ b/commands/util/generate-credit.js @@ -36,7 +36,7 @@ module.exports = class GenerateCreditCommand extends Command { }) .filter(cmds => cmds); const file = Buffer.from(`## Credits\n### NPM Packages\n${npm}\n\n### Other Credits\n${list.join('\n')}`); - await msg.direct({ files: [{ attachment: file, name: 'credits.txt' }] }); - return msg.say('📬 Sent `credits.txt` to your DMs!'); + if (msg.guild) await msg.say('📬 Sent `credits.txt` to your DMs!'); + return msg.direct({ files: [{ attachment: file, name: 'credits.txt' }] }); } }; diff --git a/commands/util/generate-process-env.js b/commands/util/generate-process-env.js index 2aa27536..e887511c 100644 --- a/commands/util/generate-process-env.js +++ b/commands/util/generate-process-env.js @@ -24,7 +24,7 @@ module.exports = class GenerateProcessEnvCommand extends Command { line = line.replace('=', ''); return `${line}="${process.env[line] || ''}"`; }).join('\n'); - await msg.direct({ files: [{ attachment: Buffer.from(list), name: 'process.env.txt' }] }); - return msg.say('📬 Sent `process.env.txt` to your DMs!'); + if (msg.guild) await msg.say('📬 Sent `process.env.txt` to your DMs!'); + return msg.direct({ files: [{ attachment: Buffer.from(list), name: 'process.env.txt' }] }); } }; diff --git a/commands/util/ip.js b/commands/util/ip.js index fbc5608f..a6b673fb 100644 --- a/commands/util/ip.js +++ b/commands/util/ip.js @@ -25,7 +25,7 @@ module.exports = class IpCommand extends Command { const { body } = await request .get('https://api.ipify.org/') .query({ format: 'json' }); - await msg.direct(body.ip); - return msg.say('📬 Sent the IP to your DMs!'); + if (msg.guild) await msg.say('📬 Sent the IP to your DMs!'); + return msg.direct(body.ip); } };