small fixes
This commit is contained in:
parent
db4e0a16dd
commit
fb807cc044
@ -16,6 +16,7 @@ class MuteCommand extends ModerationCommand {
|
||||
guildOnly: true,
|
||||
showUsage: true,
|
||||
memberPermissions: ['MODERATE_MEMBERS']
|
||||
// Mute client permissions are handled in the infraction.verify due to being able to use both timeout and role based mutes
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ class UnmuteInfraction extends Infraction {
|
||||
let removedRoles = [],
|
||||
muteType = null,
|
||||
role = null;
|
||||
const settings = await this.guild.settings(),
|
||||
now = Date.now();
|
||||
|
||||
let callback = null;
|
||||
const memberWrapper = await this.guild.memberWrapper(this.member);
|
||||
@ -53,18 +55,19 @@ class UnmuteInfraction extends Infraction {
|
||||
muteType = callback.infraction.data.muteType; //eslint-disable-line prefer-destructuring
|
||||
role = callback.infraction.data.muteRole; //eslint-disable-line prefer-destructuring
|
||||
} else {
|
||||
role = this.guild._settings.mute.role; //eslint-disable-line prefer-destructuring
|
||||
role = settings.mute.role; //eslint-disable-line prefer-destructuring
|
||||
}
|
||||
}
|
||||
|
||||
if (!removedRoles) removedRoles = []; // So it doesn't error out later if the property is undefined
|
||||
role = await this.guild.resolveRole(role);
|
||||
// The role used in the mute was probably deleted but an unmute was attempted?
|
||||
// Idk which would be the ideal solution,
|
||||
// to attempt removing the default role anyway or throw an error due to unexpected state
|
||||
// doing this for now
|
||||
if (!role) role = await this.guild.resolveRole(this.guild._settings.mute.role);
|
||||
|
||||
if (!callback) {
|
||||
if (!role) role = await this.guild.resolveRole(settings.mute.role);
|
||||
|
||||
if (!callback && settings.mute.type < 3) {
|
||||
if (role && this.member.roles.cache.has(role.id)) {
|
||||
try {
|
||||
this.member.roles.remove(role, this._reason);
|
||||
@ -75,6 +78,7 @@ class UnmuteInfraction extends Infraction {
|
||||
return this._fail('C_UNMUTE_CANNOTFINDMUTE');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const roles = [...new Set([...this.member.roles.cache.map((r) => r.id), ...removedRoles])];
|
||||
|
||||
@ -107,6 +111,10 @@ class UnmuteInfraction extends Infraction {
|
||||
return this._fail('C_UNMUTE_3FAIL');
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// Unironically hate this property name, why is it so cumbersome
|
||||
if (this.member.communicationDisabledUntilTimestamp > now) await this.member.timeout(null, this._reason);
|
||||
break;
|
||||
}
|
||||
|
||||
if(callback) this.client.moderationManager.removeCallback(callback);
|
||||
|
@ -406,8 +406,13 @@ class Infraction {
|
||||
};
|
||||
const member = await this.guild.memberWrapper(this.target);
|
||||
const callback = await member.getCallback(this.type, true);
|
||||
|
||||
this.duration = duration;
|
||||
|
||||
if (this.data.muteType === 3) {
|
||||
const time = this.callback - Date.now();
|
||||
await member.timeout(time < 0 ? null : time, `Duration edit of case ${this.case}`);
|
||||
}
|
||||
|
||||
if(callback) await this.client.moderationManager.removeCallback(callback);
|
||||
await this.client.moderationManager.handleCallbacks([this.json]);
|
||||
|
||||
@ -442,7 +447,7 @@ class Infraction {
|
||||
return infraction;
|
||||
}
|
||||
|
||||
this._patch(data);
|
||||
await this._patch(data);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ class SettingsCommand extends SlashCommand {
|
||||
if (!result.error) {
|
||||
settings[setting.name] = _setting;
|
||||
await guild.updateSettings(settings);
|
||||
await invoker.reply({ ...obj, emoji: 'success', _edit: invoker.replied });
|
||||
const emoji = result.emoji ? result.emoji : 'success';
|
||||
await invoker.reply({ ...obj, emoji, _edit: invoker.replied });
|
||||
} else {
|
||||
await invoker.reply({ ...obj, emoji: 'failure', _edit: invoker.replied });
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ class SettingsMigrator {
|
||||
settings.mute = {
|
||||
role: result.muterole || null,
|
||||
type: result.mutetype || 0,
|
||||
defaultDuration: 3600,
|
||||
default: 3600,
|
||||
permanent: false
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user