diff options
-rw-r--r-- | src/lib/utils/BushConstants.ts | 96 | ||||
-rw-r--r-- | src/listeners/contextCommands/contextCommandStarted.ts | 23 | ||||
-rw-r--r-- | src/listeners/ws/INTERACTION_CREATE.ts | 6 |
3 files changed, 30 insertions, 95 deletions
diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 9befc5a..f0f6324 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -1,3 +1,4 @@ +import { ArgumentMatches, ArgumentTypes, BuiltInReasons, CommandHandlerEvents } from 'discord-akairo/dist/src/util/Constants.js'; import { Colors, GuildFeature } from 'discord.js'; import { BushClientUtil } from '../extensions/discord-akairo/BushClientUtil.js'; @@ -449,72 +450,11 @@ export class BushConstants { } as const); public static ArgumentMatches = Object.freeze({ - PHRASE: 'phrase', - FLAG: 'flag', - OPTION: 'option', - REST: 'rest', - SEPARATE: 'separate', - TEXT: 'text', - CONTENT: 'content', - REST_CONTENT: 'restContent', - NONE: 'none' + ...ArgumentMatches } as const); public static ArgumentTypes = Object.freeze({ - STRING: 'string', - LOWERCASE: 'lowercase', - UPPERCASE: 'uppercase', - CHAR_CODES: 'charCodes', - NUMBER: 'number', - INTEGER: 'integer', - BIGINT: 'bigint', - EMOJINT: 'emojint', - URL: 'url', - DATE: 'date', - COLOR: 'color', - USER: 'user', - USERS: 'users', - MEMBER: 'member', - MEMBERS: 'members', - RELEVANT: 'relevant', - RELEVANTS: 'relevants', - CHANNEL: 'channel', - CHANNELS: 'channels', - TEXT_CHANNEL: 'textChannel', - TEXT_CHANNELS: 'textChannels', - VOICE_CHANNEL: 'voiceChannel', - VOICE_CHANNELS: 'voiceChannels', - CATEGORY_CHANNEL: 'categoryChannel', - CATEGORY_CHANNELS: 'categoryChannels', - NEWS_CHANNEL: 'newsChannel', - NEWS_CHANNELS: 'newsChannels', - STORE_CHANNEL: 'storeChannel', - STORE_CHANNELS: 'storeChannels', - STAGE_CHANNEL: 'stageChannel', - STAGE_CHANNELS: 'stageChannels', - THREAD_CHANNEL: 'threadChannel', - THREAD_CHANNELS: 'threadChannels', - ROLE: 'role', - ROLES: 'roles', - EMOJI: 'emoji', - EMOJIS: 'emojis', - GUILD: 'guild', - GUILDS: 'guilds', - MESSAGE: 'message', - GUILD_MESSAGE: 'guildMessage', - RELEVANT_MESSAGE: 'relevantMessage', - INVITE: 'invite', - USER_MENTION: 'userMention', - MEMBER_MENTION: 'memberMention', - CHANNEL_MENTION: 'channelMention', - ROLE_MENTION: 'roleMention', - EMOJI_MENTION: 'emojiMention', - COMMAND_ALIAS: 'commandAlias', - COMMAND: 'command', - INHIBITOR: 'inhibitor', - LISTENER: 'listener', - TASK: 'task', - CONTEXT_MENU_COMMAND: 'contextMenuCommand', + ...ArgumentTypes, DURATION: 'duration', CONTENT_WITH_DURATION: 'contentWithDuration', PERMISSION: 'permission', @@ -526,14 +466,7 @@ export class BushConstants { } as const); public static BlockedReasons = Object.freeze({ - CLIENT: 'client', - BOT: 'bot', - OWNER: 'owner', - SUPER_USER: 'superUser', - GUILD: 'guild', - DM: 'dm', - AUTHOR_NOT_FOUND: 'authorNotFound', - NOT_NSFW: 'notNsfw', + ...BuiltInReasons, DISABLED_GUILD: 'disabledGuild', DISABLED_GLOBAL: 'disabledGlobal', ROLE_BLACKLIST: 'roleBlacklist', @@ -546,26 +479,7 @@ export class BushConstants { } as const); public static CommandHandlerEvents = Object.freeze({ - COMMAND_BLOCKED: 'commandBlocked', - COMMAND_BREAKOUT: 'commandBreakout', - COMMAND_CANCELLED: 'commandCancelled', - COMMAND_FINISHED: 'commandFinished', - COMMAND_INVALID: 'commandInvalid', - COMMAND_LOCKED: 'commandLocked', - COMMAND_STARTED: 'commandStarted', - COOLDOWN: 'cooldown', - ERROR: 'error', - IN_PROMPT: 'inPrompt', - MESSAGE_BLOCKED: 'messageBlocked', - MESSAGE_INVALID: 'messageInvalid', - MISSING_PERMISSIONS: 'missingPermissions', - SLASH_BLOCKED: 'slashBlocked', - SLASH_ERROR: 'slashError', - SLASH_FINISHED: 'slashFinished', - SLASH_MISSING_PERMISSIONS: 'slashMissingPermissions', - SLASH_NOT_FOUND: 'slashNotFound', - SLASH_STARTED: 'slashStarted', - SLASH_ONLY: 'slashOnly' + ...CommandHandlerEvents } as const); public static moulberryBushRoleMap = BushClientUtil.deepFreeze([ diff --git a/src/listeners/contextCommands/contextCommandStarted.ts b/src/listeners/contextCommands/contextCommandStarted.ts index 91eceaa..c1fec6a 100644 --- a/src/listeners/contextCommands/contextCommandStarted.ts +++ b/src/listeners/contextCommands/contextCommandStarted.ts @@ -1,6 +1,7 @@ import { BushListener } from '#lib'; +import { Severity } from '@sentry/types'; import { ContextMenuCommandHandlerEvents } from 'discord-akairo'; -import { ChannelType } from 'discord.js'; +import { ApplicationCommandType, ChannelType } from 'discord.js'; export default class ContextCommandStartedListener extends BushListener { public constructor() { @@ -12,6 +13,26 @@ export default class ContextCommandStartedListener extends BushListener { } public override async exec(...[interaction, command]: ContextMenuCommandHandlerEvents['started']) { + client.sentry.addBreadcrumb({ + message: `[contextCommandStarted] The ${command.id} was started by ${interaction.user.tag}.`, + level: Severity.Info, + timestamp: Date.now(), + data: { + 'command.name': command?.id, + 'interaction.id': interaction.id, + 'interaction.commandType': ApplicationCommandType[interaction.commandType] ?? interaction.commandType, + 'interaction.targetId': interaction.targetId, + 'channel.id': + (interaction.channel?.isDMBased() ? interaction.channel.recipient?.id : interaction.channel?.id) ?? '¯\\_(ツ)_/¯', + 'channel.name': + (interaction.channel?.isDMBased() ? interaction.channel.recipient?.tag : (<any>interaction.channel)?.name) ?? + '¯\\_(ツ)_/¯', + 'guild.id': interaction.guild?.id ?? '¯\\_(ツ)_/¯', + 'guild.name': interaction.guild?.name ?? '¯\\_(ツ)_/¯', + 'environment': client.config.environment + } + }); + return void client.logger.info( 'contextCommandStarted', `The <<${command.id}>> command was used by <<${interaction.user.tag}>> in ${ diff --git a/src/listeners/ws/INTERACTION_CREATE.ts b/src/listeners/ws/INTERACTION_CREATE.ts index 6bd37fc..d3ca70c 100644 --- a/src/listeners/ws/INTERACTION_CREATE.ts +++ b/src/listeners/ws/INTERACTION_CREATE.ts @@ -1,4 +1,4 @@ -import { BushListener, BushUser, Moderation, ModLog, PunishmentTypePresent } from '#lib'; +import { BushListener, BushUser, Moderation, PunishmentTypePresent } from '#lib'; import { EmbedBuilder } from '@discordjs/builders'; import assert from 'assert'; import { @@ -125,7 +125,7 @@ export default class WsInteractionCreateListener extends BushListener { interaction.data.custom_id.startsWith('appeal_accept;') || interaction.data.custom_id.startsWith('appeal_deny;') ) { - const [action, punishment, guildId, userId, modlogCase] = interaction.data.custom_id.split(';') as [ + const [action, punishment, guildId, userId /* modlogCase */] = interaction.data.custom_id.split(';') as [ 'appeal_accept' | 'appeal_deny', PunishmentTypePresent, Snowflake, @@ -191,7 +191,7 @@ export default class WsInteractionCreateListener extends BushListener { const user = new BushUser(client, interaction.user as any); assert(user); - const caseId = await ModLog.findOne({ where: { user: userId, guild: guildId, id: modlogCase } }); + // const caseId = await ModLog.findOne({ where: { user: userId, guild: guildId, id: modlogCase } }); const embed = new EmbedBuilder() .setTitle(`${util.capitalize(punishment)} Appeal`) |