all repos — stealth-developers @ f93551c2f70938fc10d0a5c77b6e42b4e92c0073

feat(bot): interaction logging
vi did:web:vt3e.cat
Mon, 25 May 2026 08:51:56 +0100
commit

f93551c2f70938fc10d0a5c77b6e42b4e92c0073

parent

e56ffc6f58eb621dc8e9b68195f237702230fcab

1 files changed, 66 insertions(+), 5 deletions(-)

jump to
M pkgs/bot/src/events/interactionCreate.tspkgs/bot/src/events/interactionCreate.ts

@@ -10,15 +10,25 @@ event: Events.InteractionCreate,

async execute(client: Client, interaction: BaseInteraction) { if (interaction.isCommand()) { const command = commands.get(interaction.commandName); - logger.info(`received command ${interaction.commandName}`); + const sub = interaction.isChatInputCommand() ? interaction.options.getSubcommand() : null; + const commandString = sub ? `${interaction.commandName}/${sub}` : interaction.commandName; + + logger.info( + { + command: commandString, + user: { + id: interaction.user.id, + discriminator: interaction.user.tag, + }, + }, + `received chat input interaction`, + ); + if (!command || !command.execute) return; try { await command.execute(client, interaction); } catch (error) { - logger.error( - error, - `there was an error while executing ${interaction.commandName}`, - ); + logger.error(error, `there was an error while executing ${interaction.commandName}`); if (interaction.deferred || interaction.replied) { await interaction.followUp({

@@ -35,6 +45,19 @@ }

} else if (interaction.isButton()) { const { commandName } = parseComponentId(interaction.customId); const command = commands.get(commandName); + + logger.info( + { + button: commandName, + id: interaction.customId, + user: { + id: interaction.user.id, + discriminator: interaction.user.tag, + }, + }, + "received button interaction", + ); + if (!command || !command.buttonExecute) { return interaction.reply({ content: `couldn't find the associated command (${commandName})`,

@@ -64,6 +87,19 @@ }

} else if (interaction.isModalSubmit()) { const { commandName } = parseComponentId(interaction.customId); const command = commands.get(commandName); + + logger.info( + { + modal: commandName, + id: interaction.customId, + user: { + id: interaction.user.id, + discriminator: interaction.user.tag, + }, + }, + "received modal interaction", + ); + if (!command || !command.modalExecute) return; try { await command.modalExecute(client, interaction);

@@ -87,6 +123,18 @@ }

} } else if (interaction.isAutocomplete()) { const command = commands.get(interaction.commandName); + + logger.info( + { + command: command?.data?.name, + user: { + id: interaction.user.id, + discriminator: interaction.user.tag, + }, + }, + "received autocomplete interaction", + ); + if (!command || !command.autocomplete) return; try { await command.autocomplete(interaction);

@@ -99,6 +147,19 @@ }

} else if (interaction.isStringSelectMenu()) { const { commandName } = parseComponentId(interaction.customId); const command = commands.get(commandName); + + logger.info( + { + menu: commandName, + id: interaction.customId, + user: { + id: interaction.user.id, + discriminator: interaction.user.tag, + }, + }, + "received select menu interaction", + ); + if (!command || !command.selectMenuExecute) return interaction.reply({ content: "couldn't find the associated command!",