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);