From 8452f0360b98e2c1cf8126912c771897d56ec25f Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 28 Jul 2022 14:52:30 +0300 Subject: [PATCH] small fixes --- .../en_gb/commands/en_gb_moderation.lang | 3 +++ src/middleware/Logger.js | 1 + .../components/commands/developer/Eval.js | 12 ++++++++---- .../components/commands/moderation/History.js | 14 ++++++++++---- .../components/commands/moderation/Staff.js | 2 +- .../components/inhibitors/ClientPermissions.js | 2 +- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/localization/en_gb/commands/en_gb_moderation.lang b/src/localization/en_gb/commands/en_gb_moderation.lang index 9610d97..c617f79 100644 --- a/src/localization/en_gb/commands/en_gb_moderation.lang +++ b/src/localization/en_gb/commands/en_gb_moderation.lang @@ -339,6 +339,9 @@ Failed to display cases in one embed, try a smaller page size. for {targets} //target{plural}: +[COMMAND_HISTORY_SUCCESSMODERATOR] + by {moderator} + [COMMAND_HISTORY_NO_EXPORT_PERMS] Must be admin to export moderation history. diff --git a/src/middleware/Logger.js b/src/middleware/Logger.js index 7e61a15..7d5e717 100644 --- a/src/middleware/Logger.js +++ b/src/middleware/Logger.js @@ -86,6 +86,7 @@ class Logger { webhook(text, type) { + if (!this._webhook) return; const message = text.replace(new RegExp(process.env.DISCORD_TOKEN, 'gu'), '') .replace(new RegExp(username, 'gu'), ''); diff --git a/src/structure/components/commands/developer/Eval.js b/src/structure/components/commands/developer/Eval.js index efb7d39..a1a027c 100644 --- a/src/structure/components/commands/developer/Eval.js +++ b/src/structure/components/commands/developer/Eval.js @@ -13,16 +13,20 @@ class EvalCommand extends Command { name: 'eval', aliases: ['e', 'evaluate'], restricted: true, - module: 'developer' + module: 'developer', + options: [ + { name: 'code' }, + { name: 'async', flag: true, valueOptional: true, defaultValue: true } + ] }); } - async execute(invoker, { parameters: params }) { + async execute(invoker, { code, async }) { const args = {}; // Temporary args until I figure out how I want to implement them - params = params.join(' '); - if (args.async) params = `(async () => {${params}})()`; + let params = code.value; + if (async.value) params = `(async () => {${params}})()`; const { guild, author, member, client } = invoker; //eslint-disable-line no-unused-vars let response = null; diff --git a/src/structure/components/commands/moderation/History.js b/src/structure/components/commands/moderation/History.js index c58f222..9a3346d 100644 --- a/src/structure/components/commands/moderation/History.js +++ b/src/structure/components/commands/moderation/History.js @@ -191,12 +191,18 @@ class HistoryCommand extends SlashCommand { const type = invoker.format('COMMAND_HISTORY_SUCCESSTYPE', { old: oldest?.value || false }, { code: true }); try { + let targets = ''; + if (user || channel) targets = invoker.format('COMMAND_HISTORY_SUCCESSTARGETS', { + //plural: parsed.length === 1 ? '' : 's', + targets: `**${Util.escapeMarkdown(user?.value.tag || channel?.value.name)}**` //parsed.map((p) => `**${Util.escapeMarkdown(p.display)}**`).join(' ') + }); + else if (moderator) targets = invoker.format('COMMAND_HISTORY_SUCCESSMODERATOR', { + moderator: `**${Util.escapeMarkdown(moderator.value.tag)}**` + }); + return { content: invoker.format('COMMAND_HISTORY_SUCCESS', { - targets: user || channel ? invoker.format('COMMAND_HISTORY_SUCCESSTARGETS', { - //plural: parsed.length === 1 ? '' : 's', - targets: `**${Util.escapeMarkdown(user?.value.tag || channel?.value.name)}**` //parsed.map((p) => `**${Util.escapeMarkdown(p.display)}**`).join(' ') - }) : '', + targets, type }), emoji: 'success', diff --git a/src/structure/components/commands/moderation/Staff.js b/src/structure/components/commands/moderation/Staff.js index 7290651..0035b9d 100644 --- a/src/structure/components/commands/moderation/Staff.js +++ b/src/structure/components/commands/moderation/Staff.js @@ -27,7 +27,7 @@ class StaffCommand extends SlashCommand { // const role = await guild.resolveRole(staff.role); // if(!role) return invoker.editReply({ index: 'COMMAND_STAFF_ERROR', emoji: 'failure' }); - await channel.send({ + return channel.send({ content: guild.format('COMMAND_STAFF_SUMMON', { author: author.tag, role: staff.role }), allowedMentions: { parse: ['roles'] } // roles: [staff.role], }); diff --git a/src/structure/components/inhibitors/ClientPermissions.js b/src/structure/components/inhibitors/ClientPermissions.js index 00fe8ef..5587738 100644 --- a/src/structure/components/inhibitors/ClientPermissions.js +++ b/src/structure/components/inhibitors/ClientPermissions.js @@ -13,7 +13,7 @@ class ClientPermissions extends Inhibitor { async execute(invoker, command) { - const missing = invoker.channel.permissionsFor(invoker.guild.members.me).missing(command.clientPermissions); + const missing = invoker.channel.permissionsFor(this.client.user).missing(command.clientPermissions); if (missing.length) return super._fail({ error: true, missing: missing.join(', '), silent: true }); return super._succeed();