diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-23 18:13:05 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-23 18:13:05 -0500 |
commit | a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a (patch) | |
tree | 9b0f8ed8a93c22c90512751e3f2f5937e1925760 /src/listeners/track-manual-punishments | |
parent | 5557677f1570eb564a30cfcebb6030235dc84d47 (diff) | |
download | tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.gz tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.bz2 tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.zip |
fix discord.js breaking changes, some other stuff
Diffstat (limited to 'src/listeners/track-manual-punishments')
4 files changed, 18 insertions, 16 deletions
diff --git a/src/listeners/track-manual-punishments/modlogSyncBan.ts b/src/listeners/track-manual-punishments/modlogSyncBan.ts index 7fe2f7e..88334a4 100644 --- a/src/listeners/track-manual-punishments/modlogSyncBan.ts +++ b/src/listeners/track-manual-punishments/modlogSyncBan.ts @@ -1,5 +1,5 @@ import { BushListener, BushUser, Moderation, ModLogType, type BushClientEvents } from '#lib'; -import { MessageEmbed } from 'discord.js'; +import { MessageEmbed, Permissions } from 'discord.js'; export default class ModlogSyncBanListener extends BushListener { public constructor() { @@ -12,7 +12,8 @@ export default class ModlogSyncBanListener extends BushListener { public override async exec(...[ban]: BushClientEvents['guildBanAdd']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; - if (!ban.guild.me!.permissions.has('VIEW_AUDIT_LOG')) { + if (!ban.guild.me) return; // bot was banned + if (!ban.guild.me.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { return ban.guild.error( 'modlogSyncBan', `Could not sync the manual ban of ${ban.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -22,7 +23,7 @@ export default class ModlogSyncBanListener extends BushListener { const now = new Date(); await util.sleep(0.5); // wait for audit log entry - const logs = (await ban.guild.fetchAuditLogs({ type: 'MEMBER_BAN_ADD' })).entries.filter( + const logs = (await ban.guild.fetchAuditLogs({ type: 'MemberBanAdd' })).entries.filter( (entry) => entry.target?.id === ban.user.id ); @@ -54,7 +55,7 @@ export default class ModlogSyncBanListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: ban.user.tag, - iconURL: ban.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined + iconURL: ban.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) .addField('**Action**', `${'Manual Ban'}`) .addField('**User**', `${ban.user} (${ban.user.tag})`) diff --git a/src/listeners/track-manual-punishments/modlogSyncKick.ts b/src/listeners/track-manual-punishments/modlogSyncKick.ts index 7c06c4d..f7da96f 100644 --- a/src/listeners/track-manual-punishments/modlogSyncKick.ts +++ b/src/listeners/track-manual-punishments/modlogSyncKick.ts @@ -1,5 +1,5 @@ import { BushListener, BushUser, Moderation, ModLogType, type BushClientEvents } from '#lib'; -import { MessageEmbed } from 'discord.js'; +import { MessageEmbed, Permissions } from 'discord.js'; export default class ModlogSyncKickListener extends BushListener { public constructor() { @@ -12,7 +12,8 @@ export default class ModlogSyncKickListener extends BushListener { public override async exec(...[member]: BushClientEvents['guildMemberRemove']) { if (!(await member.guild.hasFeature('logManualPunishments'))) return; - if (!member.guild.me!.permissions.has('VIEW_AUDIT_LOG')) { + if (!member.guild.me) return; // bot was removed from guild + if (!member.guild.me.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { return member.guild.error( 'modlogSyncKick', `Could not sync the potential manual kick of ${member.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -22,7 +23,7 @@ export default class ModlogSyncKickListener extends BushListener { const now = new Date(); await util.sleep(0.5); // wait for audit log entry - const logs = (await member.guild.fetchAuditLogs({ type: 'MEMBER_KICK' })).entries.filter( + const logs = (await member.guild.fetchAuditLogs({ type: 'MemberKick' })).entries.filter( (entry) => entry.target?.id === member.user.id ); @@ -54,7 +55,7 @@ export default class ModlogSyncKickListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: member.user.tag, - iconURL: member.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined + iconURL: member.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) .addField('**Action**', `${'Manual Kick'}`) .addField('**User**', `${member.user} (${member.user.tag})`) diff --git a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts index e29af7e..c28aacf 100644 --- a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts +++ b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts @@ -1,5 +1,5 @@ import { BushListener, BushUser, Moderation, ModLogType, type BushClientEvents } from '#lib'; -import { MessageEmbed } from 'discord.js'; +import { MessageEmbed, Permissions } from 'discord.js'; export default class ModlogSyncTimeoutListener extends BushListener { public constructor() { @@ -12,7 +12,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { public override async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('logManualPunishments'))) return; - if (!newMember.guild.me!.permissions.has('VIEW_AUDIT_LOG')) { + if (!newMember.guild.me!.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { return newMember.guild.error( 'modlogSyncTimeout', `Could not sync the potential manual timeout of ${newMember.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -22,7 +22,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { const now = new Date(); await util.sleep(0.5); // wait for audit log entry - const logs = (await newMember.guild.fetchAuditLogs({ type: 'MEMBER_UPDATE' })).entries.filter( + const logs = (await newMember.guild.fetchAuditLogs({ type: 'MemberUpdate' })).entries.filter( (entry) => entry.target?.id === newMember.user.id ); @@ -60,7 +60,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: newMember.user.tag, - iconURL: newMember.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined + iconURL: newMember.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) .addField('**Action**', `${newTime ? 'Manual Timeout' : 'Manual Remove Timeout'}`) .addField('**User**', `${newMember.user} (${newMember.user.tag})`) diff --git a/src/listeners/track-manual-punishments/modlogSyncUnban.ts b/src/listeners/track-manual-punishments/modlogSyncUnban.ts index 67031b0..2d28e1c 100644 --- a/src/listeners/track-manual-punishments/modlogSyncUnban.ts +++ b/src/listeners/track-manual-punishments/modlogSyncUnban.ts @@ -1,5 +1,5 @@ import { BushListener, BushUser, Moderation, ModLogType, type BushClientEvents } from '#lib'; -import { MessageEmbed } from 'discord.js'; +import { MessageEmbed, Permissions } from 'discord.js'; export default class ModlogSyncUnbanListener extends BushListener { public constructor() { @@ -12,7 +12,7 @@ export default class ModlogSyncUnbanListener extends BushListener { public override async exec(...[ban]: BushClientEvents['guildBanRemove']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; - if (!ban.guild.me!.permissions.has('VIEW_AUDIT_LOG')) { + if (!ban.guild.me!.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { return ban.guild.error( 'modlogSyncBan', `Could not sync the manual unban of ${ban.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -22,7 +22,7 @@ export default class ModlogSyncUnbanListener extends BushListener { const now = new Date(); await util.sleep(0.5); // wait for audit log entry - const logs = (await ban.guild.fetchAuditLogs({ type: 'MEMBER_BAN_REMOVE' })).entries.filter( + const logs = (await ban.guild.fetchAuditLogs({ type: 'MemberBanRemove' })).entries.filter( (entry) => entry.target?.id === ban.user.id ); @@ -54,7 +54,7 @@ export default class ModlogSyncUnbanListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: ban.user.tag, - iconURL: ban.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined + iconURL: ban.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) .addField('**Action**', `${'Manual Unban'}`) .addField('**User**', `${ban.user} (${ban.user.tag})`) |