diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-13 23:37:57 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-13 23:37:57 -0400 |
commit | b44bbd48c72765e46b904a7aa9ce473ab2e35f98 (patch) | |
tree | a63a85c19d656dddbdbc03c4b06728852a2497d7 /src | |
parent | ad25bed8ac1beb0fee578525b73f39dfa8acf992 (diff) | |
download | tanzanite-b44bbd48c72765e46b904a7aa9ce473ab2e35f98.tar.gz tanzanite-b44bbd48c72765e46b904a7aa9ce473ab2e35f98.tar.bz2 tanzanite-b44bbd48c72765e46b904a7aa9ce473ab2e35f98.zip |
automod ban button evidence
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/common/autoMod.ts | 7 | ||||
-rw-r--r-- | src/lib/common/moderation.ts | 4 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushClientEvents.d.ts | 24 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuild.ts | 6 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuildMember.ts | 58 |
5 files changed, 74 insertions, 25 deletions
diff --git a/src/lib/common/autoMod.ts b/src/lib/common/autoMod.ts index 2f88ee7..3236253 100644 --- a/src/lib/common/autoMod.ts +++ b/src/lib/common/autoMod.ts @@ -207,7 +207,12 @@ export class AutoMod { ephemeral: true }); - const result = await interaction.guild?.bushBan({ user: userId, reason, moderator: interaction.user.id }); + const result = await interaction.guild?.bushBan({ + user: userId, + reason, + moderator: interaction.user.id, + evidence: (interaction.message as BushMessage).url ?? undefined + }); if (result === 'success') return interaction.reply({ diff --git a/src/lib/common/moderation.ts b/src/lib/common/moderation.ts index 4af6ec2..c8779fc 100644 --- a/src/lib/common/moderation.ts +++ b/src/lib/common/moderation.ts @@ -70,6 +70,7 @@ export class Moderation { duration?: number; guild: BushGuildResolvable; pseudo?: boolean; + evidence?: string; }, getCaseNumber = false ): Promise<{ log: ModLog | null; caseNum: number | null }> { @@ -96,7 +97,8 @@ export class Moderation { reason: options.reason, duration: duration, guild, - pseudo: options.pseudo ?? false + pseudo: options.pseudo ?? false, + evidence: options.evidence }); const saveResult: ModLog | null = await modLogEntry.save().catch(async (e) => { await util.handleError('createModLogEntry', e); diff --git a/src/lib/extensions/discord.js/BushClientEvents.d.ts b/src/lib/extensions/discord.js/BushClientEvents.d.ts index d8f1146..4538fbb 100644 --- a/src/lib/extensions/discord.js/BushClientEvents.d.ts +++ b/src/lib/extensions/discord.js/BushClientEvents.d.ts @@ -153,7 +153,8 @@ export interface BushClientEvents extends ClientEvents { reason: string | undefined, caseID: string, duration: number, - dmSuccess?: boolean + dmSuccess?: boolean, + evidence?: string ]; bushKick: [ victim: BushGuildMember, @@ -161,7 +162,8 @@ export interface BushClientEvents extends ClientEvents { guild: BushGuild, reason: string | undefined, caseID: string, - dmSuccess: boolean + dmSuccess: boolean, + evidence?: string ]; bushMute: [ victim: BushGuildMember, @@ -170,7 +172,8 @@ export interface BushClientEvents extends ClientEvents { reason: string | undefined, caseID: string, duration: number, - dmSuccess: boolean + dmSuccess: boolean, + evidence?: string ]; bushPunishRole: [ victim: BushGuildMember, @@ -179,7 +182,8 @@ export interface BushClientEvents extends ClientEvents { reason: string | undefined, caseID: string, duration: number, - role: BushRole + role: BushRole, + evidence?: string ]; bushPunishRoleRemove: [ victim: BushGuildMember, @@ -187,7 +191,8 @@ export interface BushClientEvents extends ClientEvents { guild: BushGuild, caseID: string, reason: string | undefined, - role: BushRole + role: BushRole, + evidence?: string ]; bushPurge: [ moderator: BushUser, @@ -201,7 +206,8 @@ export interface BushClientEvents extends ClientEvents { guild: BushGuild, reason: string | undefined, caseID: string, - dmSuccess: boolean + dmSuccess: boolean, + evidence?: string ]; bushUnmute: [ victim: BushGuildMember, @@ -209,7 +215,8 @@ export interface BushClientEvents extends ClientEvents { guild: BushGuild, reason: string | undefined, caseID: string, - dmSuccess: boolean + dmSuccess: boolean, + evidence?: string ]; bushUpdateModlog: [ moderator: BushGuildMember, @@ -231,7 +238,8 @@ export interface BushClientEvents extends ClientEvents { guild: BushGuild, reason: string | undefined, caseID: string, - dmSuccess: boolean + dmSuccess: boolean, + evidence?: string ]; bushLevelUpdate: [ member: BushGuildMember, diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index 3a2ae51..8d44cd4 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -76,6 +76,7 @@ export class BushGuild extends Guild { moderator?: BushUserResolvable; duration?: number; deleteDays?: number; + evidence?: string; }): Promise< 'success' | 'missing permissions' | 'error banning' | 'error creating modlog entry' | 'error creating ban entry' > { @@ -87,6 +88,8 @@ export class BushGuild extends Guild { const moderator = (await util.resolveNonCachedUser(options.moderator!)) ?? client.user!; const ret = await (async () => { + await this.members.cache.get(user.id)?.punishDM('banned', options.reason, options.duration ?? 0); + // ban const banSuccess = await this.bans .create(user?.id ?? options.user, { @@ -103,7 +106,8 @@ export class BushGuild extends Guild { moderator: moderator.id, reason: options.reason, duration: options.duration, - guild: this + guild: this, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; caseID = modlog.id; diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index b4c136c..954342d 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -10,6 +10,7 @@ import { BushUser } from './BushUser'; interface BushPunishmentOptions { reason?: string | null; moderator?: BushGuildMember; + evidence?: string; } interface BushTimedPunishmentOptions extends BushPunishmentOptions { @@ -86,7 +87,7 @@ export class BushGuildMember extends GuildMember { super(client, data, guild); } - private async punishDM(punishment: string, reason?: string | null, duration?: number, sendFooter = true): Promise<boolean> { + public async punishDM(punishment: string, reason?: string | null, duration?: number, sendFooter = true): Promise<boolean> { const ending = await this.guild.getSetting('punishmentEnding'); const dmEmbed = ending && ending.length && sendFooter @@ -118,7 +119,8 @@ export class BushGuildMember extends GuildMember { user: this, moderator: moderator.id, reason: options.reason, - guild: this.guild + guild: this.guild, + evidence: options.evidence }, true ); @@ -152,7 +154,8 @@ export class BushGuildMember extends GuildMember { moderator: moderator.id, user: this, reason: 'N/A', - pseudo: !options.addToModlog + pseudo: !options.addToModlog, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; @@ -185,7 +188,8 @@ export class BushGuildMember extends GuildMember { options.reason ?? undefined, caseID!, options.duration ?? 0, - options.role as BushRole + options.role as BushRole, + options.evidence ); return ret; } @@ -204,7 +208,8 @@ export class BushGuildMember extends GuildMember { guild: this.guild, moderator: moderator.id, user: this, - reason: 'N/A' + reason: 'N/A', + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; @@ -237,7 +242,8 @@ export class BushGuildMember extends GuildMember { this.guild, caseID!, options.reason ?? undefined, - options.role as BushRole + options.role as BushRole, + options.evidence ); return ret; } @@ -288,7 +294,8 @@ export class BushGuildMember extends GuildMember { moderator: moderator.id, reason: options.reason, duration: options.duration, - guild: this.guild + guild: this.guild, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; @@ -323,7 +330,8 @@ export class BushGuildMember extends GuildMember { options.reason ?? undefined, caseID!, options.duration ?? 0, - dmSuccessEvent! + dmSuccessEvent!, + options.evidence ); return ret; } @@ -357,7 +365,8 @@ export class BushGuildMember extends GuildMember { user: this, moderator: moderator.id, reason: options.reason, - guild: this.guild + guild: this.guild, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; @@ -382,7 +391,16 @@ export class BushGuildMember extends GuildMember { })(); if (!['error removing mute role', 'error creating modlog entry', 'error removing mute entry'].includes(ret)) - client.emit('bushUnmute', this, moderator, this.guild, options.reason ?? undefined, caseID!, dmSuccessEvent!); + client.emit( + 'bushUnmute', + this, + moderator, + this.guild, + options.reason ?? undefined, + caseID!, + dmSuccessEvent!, + options.evidence + ); return ret; } @@ -408,7 +426,8 @@ export class BushGuildMember extends GuildMember { user: this, moderator: moderator.id, reason: options.reason, - guild: this.guild + guild: this.guild, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; caseID = modlog.id; @@ -416,7 +435,16 @@ export class BushGuildMember extends GuildMember { return 'success'; })(); if (!['error kicking', 'error creating modlog entry'].includes(ret)) - client.emit('bushKick', this, moderator, this.guild, options.reason ?? undefined, caseID!, dmSuccessEvent!); + client.emit( + 'bushKick', + this, + moderator, + this.guild, + options.reason ?? undefined, + caseID!, + dmSuccessEvent!, + options.evidence + ); return ret; } @@ -446,7 +474,8 @@ export class BushGuildMember extends GuildMember { moderator: moderator.id, reason: options.reason, duration: options.duration, - guild: this.guild + guild: this.guild, + evidence: options.evidence }); if (!modlog) return 'error creating modlog entry'; caseID = modlog.id; @@ -473,7 +502,8 @@ export class BushGuildMember extends GuildMember { options.reason ?? undefined, caseID!, options.duration ?? 0, - dmSuccessEvent! + dmSuccessEvent!, + options.evidence ); return ret; } |