From 9e5508781a648f2422b5473680217c8f715fa163 Mon Sep 17 00:00:00 2001 From: nolan Date: Sat, 12 Jun 2021 00:12:40 -0700 Subject: [PATCH] Fix channel-based infractions not logging among some other issues. --- .../client/components/commands/moderation/Removerole.js | 2 ++ structure/moderation/infractions/Addrole.js | 3 +-- structure/moderation/infractions/Removerole.js | 4 ++-- structure/moderation/infractions/Slowmode.js | 1 + structure/moderation/interfaces/Infraction.js | 7 ++----- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/structure/client/components/commands/moderation/Removerole.js b/structure/client/components/commands/moderation/Removerole.js index 69292ac..13ec66a 100644 --- a/structure/client/components/commands/moderation/Removerole.js +++ b/structure/client/components/commands/moderation/Removerole.js @@ -56,6 +56,8 @@ class RemoveroleCommand extends Command { .handleInfraction(RemoveRole, message, { targets: members, data: { + roleIds: roles.map((r) => r.id), + roleNames: roles.map((r) => r.display), roles }, reason: parameters.join(' ') diff --git a/structure/moderation/infractions/Addrole.js b/structure/moderation/infractions/Addrole.js index ddc6be3..e22968e 100644 --- a/structure/moderation/infractions/Addrole.js +++ b/structure/moderation/infractions/Addrole.js @@ -36,8 +36,6 @@ class AddroleInfraction extends Infraction { return this._fail('INFRACTION_ERROR'); } - delete this.data.roles; //before it saves to db. - await this.handle(); return this._succeed(); @@ -67,6 +65,7 @@ class AddroleInfraction extends Infraction { } description(dm) { + console.log(this.data); return `\n${this.guild.format('INFRACTION_DESCRIPTIONROLES', { plural: this.data.roleIds.length === 1 ? '' : 's', roles: dm ? this.data.roleNames.join(', ') : this.data.roleIds.map((r) => `<@&${r}>`).join(' ') diff --git a/structure/moderation/infractions/Removerole.js b/structure/moderation/infractions/Removerole.js index f8a9e7e..72fc6e5 100644 --- a/structure/moderation/infractions/Removerole.js +++ b/structure/moderation/infractions/Removerole.js @@ -10,7 +10,7 @@ class RemoveroleInfraction extends Infraction { targetType: 'USER', message: opts.message, executor: opts.executor.user, - target: opts.target, + target: opts.target.user, reason: opts.reason, guild: opts.guild, channel: opts.channel, @@ -31,7 +31,7 @@ class RemoveroleInfraction extends Infraction { async execute() { try { - await this.member.roles.remove(this.data.roles, this._reason); + await this.member.roles.remove(this.data.roleIds, this._reason); } catch(error) { return this._fail('INFRACTION_ERROR'); } diff --git a/structure/moderation/infractions/Slowmode.js b/structure/moderation/infractions/Slowmode.js index 282b5a8..baac83a 100644 --- a/structure/moderation/infractions/Slowmode.js +++ b/structure/moderation/infractions/Slowmode.js @@ -37,6 +37,7 @@ class SlowmodeInfraction extends Infraction { rateLimitPerUser: this.data.seconds }, this._reason); } catch(e) { + console.error(e); return this._fail('INFRACTION_ERROR'); } diff --git a/structure/moderation/interfaces/Infraction.js b/structure/moderation/interfaces/Infraction.js index 1fd71a8..bbe1969 100644 --- a/structure/moderation/interfaces/Infraction.js +++ b/structure/moderation/interfaces/Infraction.js @@ -122,9 +122,7 @@ class Infraction { } /* LMAOOOO PLEASE DONT JUDGE ME */ - if(this.data.roles && this.data.roles.length > 0) { - this.data.roleIds = this.data.roles.map((r) => r.id); - this.data.roleNames = this.data.roles.map((r) => r.name); + if(this.data.roles) { delete this.data.roles; } @@ -170,12 +168,11 @@ class Infraction { && (dm && !Constants.RemovedInfractions.includes(this.type))) { description += `\n${this.guild.format('INFRACTION_DESCRIPTIONJUMPTO', { name: this.hyperlink ? 'Case' : 'Message', link: this.hyperlink ? this.hyperlink : `https://discord.com/channels/${this.guildId}/${this.channelId}/${this.messageId}` })}`; } - const blah = { author: { name: `${this.target.display} (${this.targetId})`, - icon_url: this.target.displayAvatarURL() //eslint-disable-line camelcase + icon_url: this.targetIcon //eslint-disable-line camelcase }, timestamp: this.timestamp, color: this.color,