diff --git a/src/client/components/settings/logging/Moderation.ts b/src/client/components/settings/logging/Moderation.ts index 3c75b47..180ab03 100644 --- a/src/client/components/settings/logging/Moderation.ts +++ b/src/client/components/settings/logging/Moderation.ts @@ -89,17 +89,23 @@ class ModerationLog extends Setting async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings) { - const { channel, infractions, anonymous, enabled } = opts, langParams: FormatParams = {}; let index = 'SETTING_SUCCESS_ALT'; - if (anonymous) - setting.anonymous = anonymous.asBool; if (channel) + { + const ch = channel.asChannel; + const perms = ch.permissionsFor(this.client.user!); + const missing = perms?.missing([ 'ViewChannel', 'SendMessages', 'EmbedLinks' ]); + if (!missing || missing.length) + return { error: true, index: 'ERR_BOT_MISSING_PERMISSIONS', params: { missing: missing?.join(', ') || 'Any' } }; setting.channel = channel.asChannel.id; + } if (enabled) setting.enabled = enabled.asBool; + if (anonymous) + setting.anonymous = anonymous.asBool; if (infractions) { diff --git a/src/client/interfaces/Infraction.ts b/src/client/interfaces/Infraction.ts index c0d38a1..05e1fe3 100644 --- a/src/client/interfaces/Infraction.ts +++ b/src/client/interfaces/Infraction.ts @@ -191,14 +191,14 @@ class Infraction { this.#moderationLog = await this.#guild.resolveChannel(moderation.channel, true); const perms = this.#moderationLog?.permissionsFor(this.client.user!); - const missing = perms?.missing([ 'SendMessages', 'EmbedLinks' ]); + const missing = perms?.missing([ 'ViewChannel', 'SendMessages', 'EmbedLinks' ]); if (this.#moderationLog && !missing?.length) { this.#modLogId = this.#moderationLog.id; - this.#dmLogMessage = await this.#moderationLog + this.#modLogMessage = await this.#moderationLog .send({ embeds: [ await this.#embed() ] }) .catch((err) => this.logger.error(err)) ?? null; - this.#modLogMessageId = this.#dmLogMessage?.id || null; + this.#modLogMessageId = this.#modLogMessage?.id || null; } } else