diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index bc87f59..a4fdcfd 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -1,4 +1,4 @@ -const { Client, Collection, Options } = require('discord.js'); +const { Client, Collection } = require('discord.js'); const chalk = require('chalk'); const { inspect } = require('util'); diff --git a/src/structure/components/commands/utility/Poll.js b/src/structure/components/commands/utility/Poll.js index 7a792ef..acf3679 100644 --- a/src/structure/components/commands/utility/Poll.js +++ b/src/structure/components/commands/utility/Poll.js @@ -43,7 +43,7 @@ class PollCommand extends SlashCommand { required: true }] }], - guildOnly: true + guildOnly: true, }); } @@ -68,7 +68,7 @@ class PollCommand extends SlashCommand { time: 90, editReply: true }); if (!response || !response.content) return invoker.editReply({ index: 'COMMAND_POLL_TIMEOUT' }); - await response.delete(); + if(invoker.channel.permissionsFor(guild.me).has('MANAGE_MESSAGES')) await response.delete(); const { content } = response; if (content.toLowerCase() === 'stop') break; if (content.toLowerCase() === 'cancel') return invoker.editReply({ index: 'GENERAL_CANCELLED' }); diff --git a/src/structure/components/settings/logging/DmInfraction.js b/src/structure/components/settings/logging/DmInfraction.js index d1367eb..4543f19 100644 --- a/src/structure/components/settings/logging/DmInfraction.js +++ b/src/structure/components/settings/logging/DmInfraction.js @@ -44,7 +44,8 @@ class DmInfraction extends Setting { ], messages: { default: 'You were **{infraction}** {from|on} the server `{server}`, your infraction details are below.' - } + }, + anonymous: false }, definitions: { enabled: 'BOOLEAN', @@ -86,16 +87,22 @@ class DmInfraction extends Setting { name: 'enabled', description: 'Enable or disable the sending of infractions in DMs', type: 'BOOLEAN' - }) + }), + { + name: 'anonymous', + type: 'BOOLEAN', + description: 'Whether who issued the infraction is shown in moderation logs' + } ] }); } async execute(interaction, opts, setting) { - const { enabled, infractions, infraction, message } = opts; + const { enabled, infractions, infraction, message, anonymous } = opts; if (enabled) setting.enabled = enabled.value; + if (anonymous) setting.anonymous = anonymous.value; if (infractions) { const response = await this._prompt(interaction, { diff --git a/src/structure/components/settings/logging/Moderation.js b/src/structure/components/settings/logging/Moderation.js index b680c7a..e1a2eaa 100644 --- a/src/structure/components/settings/logging/Moderation.js +++ b/src/structure/components/settings/logging/Moderation.js @@ -34,7 +34,8 @@ class ModerationLog extends Setting { module: 'logging', default: { channel: null, - infractions: Infractions + infractions: Infractions, + anonymous: false }, definitions: { channel: 'GUILD_TEXT', @@ -58,15 +59,21 @@ class ModerationLog extends Setting { { name: 'set', value: 'set' }, { name: 'reset', value: 'reset' }, ] - }) + }), + { + name: 'anonymous', + type: 'BOOLEAN', + description: 'Whether who issued the infraction is shown in moderation logs' + } ] }); } async execute(interaction, opts, setting) { - const { channel, infractions } = opts; + const { channel, infractions, anonymous } = opts; + if (anonymous) setting.anonymous = anonymous.value; if (channel) setting.channel = channel.value.id; if (infractions) { diff --git a/src/structure/interfaces/Infraction.js b/src/structure/interfaces/Infraction.js index 1060cc6..0ff69d7 100644 --- a/src/structure/interfaces/Infraction.js +++ b/src/structure/interfaces/Infraction.js @@ -153,7 +153,7 @@ class Infraction { return `https://discord.com/channels/${this.guildId}/${this.channelId}/${this.messageId}`; } - _embed(dm) { + _embed(dm = false) { const embed = { author: { @@ -169,9 +169,10 @@ class Infraction { }; let description = ""; + const anonymous = dm ? this.guild._settings.dminfraction.anonymous : this.guild._settings.moderation.anonymous || false; description += `${this.guild.format('INFRACTION_DESCRIPTION', { type: this.dictionary.past.toUpperCase(), - moderator: `${Util.escapeMarkdown(this.executor.tag)}`, + moderator: `${Util.escapeMarkdown(anonymous ? this.client.user.tag : this.executor.tag)}`, reason: Util.escapeMarkdown(this.reason.length > Constants.MaxCharacters ? `${this.reason.substring(0, Constants.MaxCharacters - 3)}...` : this.reason, { italic: false, underline: false, strikethrough: false }), diff --git a/src/utilities/SettingsMigrator.js b/src/utilities/SettingsMigrator.js index 5423517..1d39e7a 100644 --- a/src/utilities/SettingsMigrator.js +++ b/src/utilities/SettingsMigrator.js @@ -185,7 +185,7 @@ class SettingsMigrator { wordfilter: result.wordFilter, linkfilter: result.linkFilter ? { ...result.linkFilter, greylist: [], mode: undefined } : undefined, messages: result.messageLog ? { ...result.messageLog, enabled: Boolean(result.messageLog.channel) } : undefined, - wordwatcher: result.wordWatcher, + wordwatcher: result.wordwatcher ? { ...result.wordWatcher, regex: [] } : undefined, invitefilter: result.inviteFilter, permissions: { type: result.permissionType || 'discord' }, premium: result.premium,