This commit is contained in:
Erik 2022-07-11 11:02:49 +03:00
parent a2b9714aa5
commit 7643256df7
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
7 changed files with 12 additions and 11 deletions

View File

@ -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();

View File

@ -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`);

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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}`);
}