diff options
author | TymanWasTaken <tyman@tyman.tech> | 2021-05-16 20:30:34 -0400 |
---|---|---|
committer | TymanWasTaken <tyman@tyman.tech> | 2021-05-16 20:30:34 -0400 |
commit | 372718e567e060cead16dde5d6d190666b4dd575 (patch) | |
tree | 1fad29305b6277838833a7e8ae4381136212f301 /src/commands | |
parent | 1db014860c3cf6070bb29f75b6a8cf08070e5b9a (diff) | |
download | tanzanite-372718e567e060cead16dde5d6d190666b4dd575.tar.gz tanzanite-372718e567e060cead16dde5d6d190666b4dd575.tar.bz2 tanzanite-372718e567e060cead16dde5d6d190666b4dd575.zip |
add colored logging and improved logging code, fix a few moderation command issues, add more logging, and make ban check run every 30s not 60s
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/admin/prefix.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/ban.ts | 26 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 18 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 18 |
5 files changed, 68 insertions, 9 deletions
diff --git a/src/commands/admin/prefix.ts b/src/commands/admin/prefix.ts index 8fb50f8..3948a7e 100644 --- a/src/commands/admin/prefix.ts +++ b/src/commands/admin/prefix.ts @@ -10,7 +10,13 @@ export default class PrefixCommand extends BotCommand { id: 'prefix' } ], - userPermissions: ['MANAGE_GUILD'] + userPermissions: ['MANAGE_GUILD'], + description: { + content: + 'Set the prefix of the current server (resets to default if prefix is not given)', + usage: 'prefix [prefix]', + examples: ['prefix', 'prefix +'] + } }); } async exec( diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index fc861dc..7ce36d3 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,4 +1,5 @@ import { User } from 'discord.js'; +import { Guild } from '../../lib/models'; import { BotCommand } from '../../lib/extensions/BotCommand'; import { BotMessage } from '../../lib/extensions/BotMessage'; import { Ban, Modlog, ModlogType } from '../../lib/models'; @@ -27,7 +28,8 @@ export default class PrefixCommand extends BotCommand { } }, { - id: 'reason' + id: 'reason', + match: 'rest' }, { id: 'time', @@ -36,7 +38,16 @@ export default class PrefixCommand extends BotCommand { } ], clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['BAN_MEMBERS'] + userPermissions: ['BAN_MEMBERS'], + description: { + content: + 'Ban a member and log it in modlogs (with optional time to unban)', + usage: 'ban <member> <reason> [--time]', + examples: [ + 'ban @Tyman being cool', + 'ban @Tyman being cool --time 7days' + ] + } }); } async exec( @@ -47,6 +58,15 @@ export default class PrefixCommand extends BotCommand { let modlogEnry: Modlog; let banEntry: Ban; const translatedTime: string[] = []; + // Create guild entry so postgres doesn't get mad when I try and add a modlog entry + await Guild.findOrCreate({ + where: { + id: message.guild.id + }, + defaults: { + id: message.guild.id + } + }); try { try { if (time) { @@ -129,8 +149,8 @@ export default class PrefixCommand extends BotCommand { ); } catch { await message.util.send('Error banning :/'); - await modlogEnry.destroy(); await banEntry.destroy(); + await modlogEnry.destroy(); return; } } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index dcd19de..23fc092 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,6 +1,6 @@ import { BotCommand } from '../../lib/extensions/BotCommand'; import { BotMessage } from '../../lib/extensions/BotMessage'; -import { Modlog, ModlogType } from '../../lib/models'; +import { Guild, Modlog, ModlogType } from '../../lib/models'; import { GuildMember } from 'discord.js'; export default class PrefixCommand extends BotCommand { @@ -21,7 +21,12 @@ export default class PrefixCommand extends BotCommand { } ], clientPermissions: ['KICK_MEMBERS'], - userPermissions: ['KICK_MEMBERS'] + userPermissions: ['KICK_MEMBERS'], + description: { + content: 'Kick a member and log it in modlogs', + usage: 'kick <member> <reason>', + examples: ['kick @Tyman being cool'] + } }); } async exec( @@ -29,6 +34,15 @@ export default class PrefixCommand extends BotCommand { { user, reason }: { user: GuildMember; reason?: string } ): Promise<void> { let modlogEnry: Modlog; + // Create guild entry so postgres doesn't get mad when I try and add a modlog entry + await Guild.findOrCreate({ + where: { + id: message.guild.id + }, + defaults: { + id: message.guild.id + } + }); try { modlogEnry = Modlog.build({ user: user.id, diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index dbb101c..320c6b4 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -22,7 +22,12 @@ export default class ModlogCommand extends BotCommand { type: 'number' } ], - userPermissions: ['MANAGE_MESSAGES'] + userPermissions: ['MANAGE_MESSAGES'], + description: { + content: "View a user's modlogs, or view a specific modlog entry", + usage: 'warn <search> [page]', + examples: ['modlogs @Tyman', 'modlogs @Tyman 3'] + } }); } *args(): unknown { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 755a036..98ba4bd 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,7 +1,7 @@ import { GuildMember } from 'discord.js'; import { BotCommand } from '../../lib/extensions/BotCommand'; import { BotMessage } from '../../lib/extensions/BotMessage'; -import { Modlog, ModlogType } from '../../lib/models'; +import { Guild, Modlog, ModlogType } from '../../lib/models'; export default class WarnCommand extends BotCommand { public constructor() { @@ -17,13 +17,27 @@ export default class WarnCommand extends BotCommand { id: 'reason', match: 'rest' } - ] + ], + description: { + content: 'Warn a member and log it in modlogs', + usage: 'warn <member> <reason>', + examples: ['warn @Tyman being cool'] + } }); } public async exec( message: BotMessage, { member, reason }: { member: GuildMember; reason: string } ): Promise<void> { + // Create guild entry so postgres doesn't get mad when I try and add a modlog entry + await Guild.findOrCreate({ + where: { + id: message.guild.id + }, + defaults: { + id: message.guild.id + } + }); try { const entry = Modlog.build({ user: member.id, |