diff --git a/src/context-menus/add-note.ts b/src/context-menus/add-note.ts new file mode 100644 index 0000000..b723442 --- /dev/null +++ b/src/context-menus/add-note.ts @@ -0,0 +1,33 @@ +import { ApplicationIntegrationType, Client, InteractionContextType, PermissionFlagsBits, ContextMenuCommandBuilder, ApplicationCommandType, UserContextMenuCommandInteraction, GuildBasedChannel, ModalBuilder, TextInputBuilder, GuildMember, TextInputStyle, ActionRowBuilder } from 'discord.js'; +import { channelIsInStaffCategory, deferInteraction, getNoteMessage, handleWhoIsInteraction } from '../utils'; + +export default { + name: 'Add Note', + data: new ContextMenuCommandBuilder() + .setName('Add Note') + .setIntegrationTypes(ApplicationIntegrationType.GuildInstall) + .setContexts(InteractionContextType.Guild) + .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers) + .setType(ApplicationCommandType.User), + handler: async function (client: Client, interaction: UserContextMenuCommandInteraction) { + const idToUse = interaction.targetUser.id; + + const member = await interaction.guild?.members.fetch(idToUse); + + const modal = new ModalBuilder() + .setCustomId(`add-note-modal_${idToUse}`) + .setTitle(`Adding note to ${member ? member.displayName : idToUse}`); + + const input = new TextInputBuilder() + .setCustomId('note-message') + .setLabel('Note message') + .setStyle(TextInputStyle.Paragraph) + .setRequired(true) + .setMinLength(2) + .setMaxLength(1500); + + modal.addComponents(new ActionRowBuilder().addComponents(input)); + + await interaction.showModal(modal); + } +}; \ No newline at end of file diff --git a/src/context-menus/notes.ts b/src/context-menus/list-notes.ts similarity index 100% rename from src/context-menus/notes.ts rename to src/context-menus/list-notes.ts diff --git a/src/modals/add-note-modal.ts b/src/modals/add-note-modal.ts new file mode 100644 index 0000000..5c5c28d --- /dev/null +++ b/src/modals/add-note-modal.ts @@ -0,0 +1,14 @@ +import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, GuildTextBasedChannel, MessageFlags, ModalSubmitInteraction, TextChannel, ThreadAutoArchiveDuration } from 'discord.js'; +import { ticketCooldownMap } from '../shared/ticket-cooldown'; +import { Database } from '../shared/Database'; + +export default { + name: 'add-note-modal', + handler: async function (client: Client, interaction: ModalSubmitInteraction, id: string) { + const message = interaction.fields.getTextInputValue('note-message'); + + await Database.putNote(id, message, interaction.user.id); + + interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Note added' }); + } +}; \ No newline at end of file