bugfixes, perms checks

This commit is contained in:
Erik 2022-08-17 12:35:04 +03:00
parent d664e98909
commit 18f61d07f6
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
6 changed files with 22 additions and 4 deletions

View File

@ -203,6 +203,9 @@ I could not find any messages with those arguments
[C_PRUNE_NODELETE]
I had issues deleting those messages
[C_PRUNE_MISSING_ACCESS]
Missing access to read messages in the channel. Ensure the bot has permissions to view channel and read message history.
//Vckick Command
[COMMAND_VCKICK_HELP]
Kick provided members from their connected voice-channel.

View File

@ -184,6 +184,7 @@ class HistoryCommand extends SlashCommand {
}
string += `\n**Reason:** \`${infraction.reason ? handleReason(infraction.reason) : '`N/A`'}\``;
if (infraction.resolved) string += `\n${guild.format('INFRACTION_RESOLVED')}`;
if (i !== results.length - 1) string += `\n${ZeroWidthChar}`; //Space out cases (as long as its not at the end)
embed.fields.push({

View File

@ -47,7 +47,7 @@ class RemindCommand extends SlashCommand {
const reminders = guild.callbacks.filter((cb) => cb.data.user === author.id).map((val) => val);
const embed = this._remindersEmbed(reminders, guild);
const msg = await invoker.promptMessage(guild.format('COMMAND_REMIND_SELECT'), { embed });
await msg.delete();
if(msg) await msg.delete();
const response = msg?.content;
if (!response) return invoker.editReply({ index: 'COMMAND_REMIND_DELETE_TIMEOUT', embeds: [] });

View File

@ -72,7 +72,7 @@ class UtilityHook extends Observer {
} else if (infraction.data.muteType === 1) {
if (!role) return;
await Util.wait(5 * 1000); //wait 5 seconds in case other bots add roles that would break the mute
await Util.wait(7.5 * 1000); //wait 5 seconds in case other bots add roles that would break the mute
const roles = member.roles.cache;
const managed = roles.find((r) => r.managed);
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
@ -84,7 +84,7 @@ class UtilityHook extends Observer {
} else if (infraction.data.muteType === 2) {
await Util.wait(5 * 1000); //wait 5 seconds in case other bots add roles that would break the mute
await Util.wait(7.5 * 1000); //wait 5 seconds in case other bots add roles that would break the mute
const roles = member.roles.cache;
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
@ -123,6 +123,9 @@ class UtilityHook extends Observer {
const _roles = await guild.resolveRoles(setting.roles);
if (_roles.some((r) => r.position >= me.roles.highest.position)) return;
const roles = _roles.map((r) => r.id);
// Sometimes the member isn't available on the API for some reason,
// seeing if waiting a bit helps, so we don't try to patch a member that's still being processed on discord's API
await Util.wait(5 * 1000);
await member.roles.add(roles, 'Adding autoroles').catch(this.logger.error.bind(this.logger));
}

View File

@ -33,7 +33,7 @@ class IndexSetting extends Setting {
if (enabled) setting.enabled = enabled.value;
if (description) setting.description = description.value;
return { index: 'SETTING_SUCCES_ALT' };
return { index: 'SETTING_SUCCESS_ALT' };
}

View File

@ -195,6 +195,17 @@ class PruneInfraction extends Infraction {
return `\n${this.guild.format('INFRACTION_DESCRIPTIONAMOUNT', { amount: this.data.amount })}`;
}
async verify() {
const me = await this.guild.resolveMember(this.client.user);
const perms = this.target.permissionsFor(me);
if (perms.missing('ViewChannel', 'ReadMessageHistory').length) return this._fail('C_PRUNE_MISSING_ACCESS', true);
if (perms.missing('ManageMessages').length) return this._fail('C_PRUNE_INSUFFICIENTPERMISSIONS', true);
return super._verify();
}
}
module.exports = PruneInfraction;