From e9c45b1907e093c38a4f6711f17a17ccb833e7e9 Mon Sep 17 00:00:00 2001 From: Nix Krystik Date: Sat, 16 May 2026 04:53:41 +0800 Subject: [PATCH] Proof-of-concept for silent message reports. --- src/context-menus/report.ts | 45 +++++++++++++++++++++++++++++++++++++ src/index.ts | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/context-menus/report.ts diff --git a/src/context-menus/report.ts b/src/context-menus/report.ts new file mode 100644 index 0000000..7a364f2 --- /dev/null +++ b/src/context-menus/report.ts @@ -0,0 +1,45 @@ +import { ApplicationCommandType, ApplicationIntegrationType, Client, ContextMenuCommandBuilder, GuildTextBasedChannel, InteractionContextType, MessageContextMenuCommandInteraction, MessageFlags } from "discord.js"; + +// TODO: Later Nix's problem: Command Cooldown. + +export default { + name: 'Report Message', + data: new ContextMenuCommandBuilder() + .setName('Report Message') + .setIntegrationTypes(ApplicationIntegrationType.GuildInstall) + .setContexts(InteractionContextType.Guild) + .setType(ApplicationCommandType.Message), + + handler: async function (client: Client, interaction: MessageContextMenuCommandInteraction) { + try { + const reportsChannel = await client.channels.fetch("1504936076081369150") as GuildTextBasedChannel; + + reportsChannel.send({ + embeds: [{ + title: 'New Message Report!', + fields: [ + { name: 'Message', value: interaction.targetMessage.url, inline: false }, + { name: 'Author', value: interaction.targetMessage.author.toString(), inline: false }, + { name: 'Reporter', value: interaction.user.toString(), inline: false } + ] + }] + }); + + interaction.reply({ + embeds: [{ + color: 0x014995, + description: "Thanks for making a report! Moderators have been notified and will investigate when they can next!" + }], + + flags: [MessageFlags.Ephemeral] + }); + } catch (error) { + interaction.reply({ + embeds: [{ + color: 0xff5555, + description: "Hmm, an error occured while processing your request. If you receive this error more than once, DM a moderator for assistance." + }] + }) + } + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 9c19610..85119e5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -121,7 +121,7 @@ client.on('interactionCreate', async (interaction) => { } }); -client.on('ready', async () => { +client.on('clientReady', async () => { console.log(`Logged in as ${client.user!.tag}!`); await refreshCommands(client);