bugfixes, perms checks
This commit is contained in:
parent
d664e98909
commit
18f61d07f6
@ -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.
|
||||
|
@ -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({
|
||||
|
@ -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: [] });
|
||||
|
@ -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));
|
||||
|
||||
}
|
||||
|
@ -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' };
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
Loading…
Reference in New Issue
Block a user