diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-14 13:29:19 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-14 13:29:19 -0400 |
commit | eaaae08aeee1fa16a4e1ad0b26fceb42885bfcde (patch) | |
tree | 6c1501af87225b478c9ebdc39e0712e0d4835a08 | |
parent | 070b5f326d0647e7b105f99811e4bdc915c8652e (diff) | |
download | tanzanite-eaaae08aeee1fa16a4e1ad0b26fceb42885bfcde.tar.gz tanzanite-eaaae08aeee1fa16a4e1ad0b26fceb42885bfcde.tar.bz2 tanzanite-eaaae08aeee1fa16a4e1ad0b26fceb42885bfcde.zip |
add punishent footer command
-rw-r--r-- | src/commands/config/muteRole.ts | 4 | ||||
-rw-r--r-- | src/commands/config/prefix.ts | 2 | ||||
-rw-r--r-- | src/commands/config/punishmentFooter.ts | 51 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuildMember.ts | 8 | ||||
-rw-r--r-- | src/tasks/removePunishmentRole.ts | 9 |
5 files changed, 63 insertions, 11 deletions
diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index 9a172be..1bec4a9 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -8,8 +8,8 @@ export default class MuteRoleCommand extends BushCommand { category: 'config', description: { content: 'Configure what role to use when muting users.', - usage: 'prefix [prefix]', - examples: ['prefix', 'prefix +'] + usage: 'muterole <role>', + examples: ['muterole 748912426581229690'] }, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index dc51671..4624e99 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -8,7 +8,7 @@ export default class PrefixCommand extends BushCommand { description: { content: 'Set or reset the prefix for the server.', usage: 'prefix [prefix]', - examples: ['prefix', 'prefix +'] + examples: ['prefix', 'prefix -'] }, clientPermissions: ['SEND_MESSAGES'], userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], diff --git a/src/commands/config/punishmentFooter.ts b/src/commands/config/punishmentFooter.ts new file mode 100644 index 0000000..3a246df --- /dev/null +++ b/src/commands/config/punishmentFooter.ts @@ -0,0 +1,51 @@ +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { Util } from 'discord.js'; + +export default class PunishmentFooterCommand extends BushCommand { + public constructor() { + super('punishmentFooter', { + aliases: ['punishmentfooter'], + category: 'config', + description: { + content: 'Configure or reset what should follow all punishment related dms.', + usage: 'punishmentfooter [message]', + examples: ['punishmentfooter', 'prefix you can appeal at https://example.com.'] + }, + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'], + args: [ + { + id: 'ending', + type: 'string', + match: 'restContent', + prompt: { + start: 'What message would you like to follow punishment dms?', + retry: '{error} Choose a valid role.', + optional: true + } + } + ], + slash: true, + slashOptions: [ + { + name: 'ending', + description: 'What message would you like to follow punishment dms?', + type: 'STRING', + required: false + } + ] + }); + } + + async exec(message: BushMessage | BushSlashMessage, args: { ending: string }): Promise<unknown> { + await message.guild.setSetting('punishmentEnding', args.ending || null); + if (args.ending) + return await message.util.send({ + content: `${ + this.client.util.emojis.success + } Changed the server's punishment footer to \n\`\`\`${Util.cleanCodeBlockContent(args.ending)}\`\`\`.`, + allowedMentions: AllowedMentions.none() + }); + else return await message.util.send(`${this.client.util.emojis.success} Removed he server's punishment footer.`); + } +} diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index 8e1c51a..4bb1c2c 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -15,16 +15,12 @@ interface BushTimedPunishmentOptions extends BushPunishmentOptions { duration?: number; } -interface AddRoleOptions { - moderator?: BushUserResolvable; - duration?: number; +interface AddRoleOptions extends BushTimedPunishmentOptions { role: BushRole | Role; addToModlog: boolean; } -interface RemoveRoleOptions { - moderator?: BushUserResolvable; - duration?: number; +interface RemoveRoleOptions extends BushTimedPunishmentOptions { role: BushRole | Role; addToModlog: boolean; } diff --git a/src/tasks/removePunishmentRole.ts b/src/tasks/removePunishmentRole.ts index d957238..9830338 100644 --- a/src/tasks/removePunishmentRole.ts +++ b/src/tasks/removePunishmentRole.ts @@ -16,13 +16,18 @@ export default class RemovePunishmentRole extends BushTask { for (const entry of expiredEntries) { const guild = this.client.guilds.cache.get(entry.guild); - if (!guild) { + const role = guild?.roles?.cache?.get(entry.role); + if (!guild || !role) { await entry.destroy(); continue; } const member = guild.members.cache.get(entry.user) as BushGuildMember; - const result = await member.removePunishRole({ reason: 'Punishment expired.', role: entry.role }); + const result = await member.removeRole({ + reason: 'Punishment expired.', + role: role, + addToModlog: true + }); if (['success', 'failed to dm'].includes(result)) await entry.destroy(); else throw result; |