diff --git a/src/structure/components/commands/information/Info.js b/src/structure/components/commands/information/Info.js index a265f38..b1b1343 100644 --- a/src/structure/components/commands/information/Info.js +++ b/src/structure/components/commands/information/Info.js @@ -46,7 +46,7 @@ class InformationCommand extends SlashCommand { async _user(interaction, user) { - const member = await interaction.guild?.memberWrapper(user) || null; //await interaction.guild.members.fetch(user.id).catch(() => null); + const member = await interaction.guild?.memberWrapper(user).catch(() => null) || null; //await interaction.guild.members.fetch(user.id).catch(() => null); const activities = member?.presence?.activities || []; const flags = user.flags || await user.fetchFlags(); diff --git a/src/structure/components/commands/moderation/History.js b/src/structure/components/commands/moderation/History.js index 7f0dac4..3995e7a 100644 --- a/src/structure/components/commands/moderation/History.js +++ b/src/structure/components/commands/moderation/History.js @@ -177,8 +177,8 @@ class HistoryCommand extends SlashCommand { async _exportLogs(invoker, priv = false) { - const member = await invoker.memberWrapper(); - if(!member.isAdmin()) return { emoji: 'failure', index: 'COMMAND_HISTORY_NO_EXPORT_PERMS' }; + const member = await invoker.memberWrapper().catch(() => null); + if(!member || !member.isAdmin()) return { emoji: 'failure', index: 'COMMAND_HISTORY_NO_EXPORT_PERMS' }; const logs = await this.client.storageManager.mongodb.infractions.find({ guild: invoker.guild.id }, { projection: { _id: 0 } }); const string = JSON.stringify(logs); const attachment = new MessageAttachment(Buffer.from(string), `${invoker.guild.id}-moderation.json`); diff --git a/src/structure/components/infractions/Mute.js b/src/structure/components/infractions/Mute.js index 179c177..22abb15 100644 --- a/src/structure/components/infractions/Mute.js +++ b/src/structure/components/infractions/Mute.js @@ -154,7 +154,7 @@ class MuteInfraction extends Infraction { error = false; const { removedRoles, muteType, muteRole } = this.data; - const member = await this.guild.memberWrapper(this.targetId); + const member = await this.guild.memberWrapper(this.targetId).catch(() => null); const callback = await member.getCallback(this.type); if (callback) this.client.moderationManager.removeCallback(callback); diff --git a/src/structure/components/infractions/Unmute.js b/src/structure/components/infractions/Unmute.js index 4f58f0b..5f3983e 100644 --- a/src/structure/components/infractions/Unmute.js +++ b/src/structure/components/infractions/Unmute.js @@ -43,7 +43,7 @@ class UnmuteInfraction extends Infraction { now = Date.now(); let callback = null; - const memberWrapper = await this.guild.memberWrapper(this.member); + const memberWrapper = await this.guild.memberWrapper(this.member).catch(() => null); if (Object.keys(this.data).length) { removedRoles = this.data.removedRoles; //eslint-disable-line prefer-destructuring muteType = this.data.muteType; //eslint-disable-line prefer-destructuring diff --git a/src/structure/components/inhibitors/ChannelIgnore.js b/src/structure/components/inhibitors/ChannelIgnore.js index efe2f1b..736df49 100644 --- a/src/structure/components/inhibitors/ChannelIgnore.js +++ b/src/structure/components/inhibitors/ChannelIgnore.js @@ -13,8 +13,8 @@ class ChannelIgnore extends Inhibitor { async execute(invoker) { - const member = await invoker.memberWrapper(); - if (await member.isAdmin()) return super._succeed(); + const member = await invoker.memberWrapper().catch(() => null); + if (!member || await member.isAdmin()) return super._succeed(); const { guild, channel } = invoker; const settings = await guild.settings(); diff --git a/src/structure/components/inhibitors/Permissions.js b/src/structure/components/inhibitors/Permissions.js index f6e71ce..074f8b3 100644 --- a/src/structure/components/inhibitors/Permissions.js +++ b/src/structure/components/inhibitors/Permissions.js @@ -17,7 +17,7 @@ class Permissions extends Inhibitor { async execute(invoker, command, override = null) { - const userWrapper = await invoker.memberWrapper(); + const userWrapper = await invoker.memberWrapper().catch(() => null); if (await userWrapper.isAdmin()) return super._succeed(); const { guild, member } = invoker; diff --git a/src/structure/interfaces/Infraction.js b/src/structure/interfaces/Infraction.js index cd17930..ac0705e 100644 --- a/src/structure/interfaces/Infraction.js +++ b/src/structure/interfaces/Infraction.js @@ -406,11 +406,12 @@ class Infraction { timestamp: now, duration: this.duration }; - const member = await this.guild.memberWrapper(this.target); - const callback = await member.getCallback(this.type, true); + const member = await this.guild.memberWrapper(this.target).catch(() => null); + // const callback = await member.getCallback(this.type, true); + const callback = this.client.moderationManager.callbacks.get(this.id); this.duration = duration; - if (this.data.muteType === 3) { + if (this.data.muteType === 3 && member) { const time = this.callback - Date.now(); await member.timeout(time < 0 ? null : time, `Duration edit of case ${this.case}`); }