forked from Galactic/galactic-bot
proper perms checks
This commit is contained in:
parent
dbf3dd8ed9
commit
7ca623c3c7
@ -89,17 +89,23 @@ class ModerationLog extends Setting
|
|||||||
|
|
||||||
async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings)
|
async execute (invoker: InvokerWrapper, opts: CommandParams, setting: ModerationSettings)
|
||||||
{
|
{
|
||||||
|
|
||||||
const { channel, infractions, anonymous, enabled } = opts,
|
const { channel, infractions, anonymous, enabled } = opts,
|
||||||
langParams: FormatParams = {};
|
langParams: FormatParams = {};
|
||||||
let index = 'SETTING_SUCCESS_ALT';
|
let index = 'SETTING_SUCCESS_ALT';
|
||||||
|
|
||||||
if (anonymous)
|
|
||||||
setting.anonymous = anonymous.asBool;
|
|
||||||
if (channel)
|
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;
|
setting.channel = channel.asChannel.id;
|
||||||
|
}
|
||||||
if (enabled)
|
if (enabled)
|
||||||
setting.enabled = enabled.asBool;
|
setting.enabled = enabled.asBool;
|
||||||
|
if (anonymous)
|
||||||
|
setting.anonymous = anonymous.asBool;
|
||||||
|
|
||||||
if (infractions)
|
if (infractions)
|
||||||
{
|
{
|
||||||
|
@ -191,14 +191,14 @@ class Infraction
|
|||||||
{
|
{
|
||||||
this.#moderationLog = await this.#guild.resolveChannel<TextChannel>(moderation.channel, true);
|
this.#moderationLog = await this.#guild.resolveChannel<TextChannel>(moderation.channel, true);
|
||||||
const perms = this.#moderationLog?.permissionsFor(this.client.user!);
|
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)
|
if (this.#moderationLog && !missing?.length)
|
||||||
{
|
{
|
||||||
this.#modLogId = this.#moderationLog.id;
|
this.#modLogId = this.#moderationLog.id;
|
||||||
this.#dmLogMessage = await this.#moderationLog
|
this.#modLogMessage = await this.#moderationLog
|
||||||
.send({ embeds: [ await this.#embed() ] })
|
.send({ embeds: [ await this.#embed() ] })
|
||||||
.catch((err) => this.logger.error(err)) ?? null;
|
.catch((err) => this.logger.error(err)) ?? null;
|
||||||
this.#modLogMessageId = this.#dmLogMessage?.id || null;
|
this.#modLogMessageId = this.#modLogMessage?.id || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user