2 Commits
Author SHA1 Message Date
nxbat 62001bcbbf (modals): Add Modal<Context> interface. 2026-10-25 09:38:06 +00:00
nxbat 567916dafb [Buttons] Closed ticket threads now prefix [CLOSED] (#23) 2026-10-20 06:37:55 -07:00
3 changed files with 14 additions and 20 deletions
+3 -6
View File
@@ -1,4 +1,5 @@
import { ButtonInteraction, Client, MessageFlags, ChannelType, PermissionFlagsBits } from 'discord.js'; import { ButtonInteraction, Client, MessageFlags, ChannelType, PermissionFlagsBits } from 'discord.js';
import { closeTicket } from '../utils';
export default { export default {
name: 'close-mod-ticket', name: 'close-mod-ticket',
@@ -19,13 +20,9 @@ export default {
components: [] components: []
}); });
await channel.send('This ticket has been closed by staff.'); if (!await closeTicket(client, channel, 'This ticket has been closed by staff.'))
return await interaction.editReply({ content: 'An error occurred while trying to close this ticket.' });
await interaction.editReply({ content: 'Ticket closed.' }); await interaction.editReply({ content: 'Ticket closed.' });
channel.edit({
archived: true,
locked: true
});
} }
}; };
+10 -12
View File
@@ -1,28 +1,26 @@
import { ButtonInteraction, Client, MessageFlags, ChannelType } from 'discord.js'; import { ButtonInteraction, Client, MessageFlags, ChannelType } from 'discord.js';
import { Database } from '../shared/Database'; import { closeTicket } from '../utils';
export default { export default {
name: 'close-ticket', name: 'close-ticket',
handler: async function (client: Client, interaction: ButtonInteraction) { handler: async function (client: Client, interaction: ButtonInteraction) {
const channel = await interaction.channel?.fetch(); const channel = await interaction.channel?.fetch();
if (!channel || !channel.isThread() || !channel.isSendable() || channel.type != ChannelType.PrivateThread) if (!channel || !channel.isThread() || !channel.isSendable() || channel.type != ChannelType.PrivateThread)
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Oops. Something went wrong. Please report this to a staff member.' }); return await interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Oops. Something went wrong. Please report this to a staff member.' });
await interaction.reply({
content: 'Closing, please wait...',
flags: MessageFlags.Ephemeral
});
await interaction.message.edit({ await interaction.message.edit({
content: interaction.message.content, content: interaction.message.content,
components: [] components: []
}); });
await Database.closePrivateHelpTicket(channel.id); if (!await closeTicket(client, channel, `This ticket has been closed by ${interaction.user}`))
return await interaction.editReply({ content: 'An error occurred while trying to close this ticket.' });
await channel.send(`This ticket has been closed by ${interaction.user}`); await interaction.editReply({ content: 'Ticket closed.' });
await interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Ticket closed.' });
channel.edit({
archived: true,
locked: true
});
} }
}; };
+1 -2
View File
@@ -121,9 +121,8 @@ export async function openModTicketModal(interaction: UserContextMenuCommandInte
const titleLabel = createTextInput('title', 'Title', `The name of the thread. Defaults to "Mod Ticket For ${member.displayName}" if left empty`, false, TextInputStyle.Short, 100, null); const titleLabel = createTextInput('title', 'Title', `The name of the thread. Defaults to "Mod Ticket For ${member.displayName}" if left empty`, false, TextInputStyle.Short, 100, null);
const initialMessageLabel = createTextInput('initial-message', 'Inital Message', 'The inital message sent in the thread', false, TextInputStyle.Paragraph, 1800, null); const initialMessageLabel = createTextInput('initial-message', 'Inital Message', 'The inital message sent in the thread', false, TextInputStyle.Paragraph, 1800, null);
const autoJoinLabel = createCheckbox('auto-join-thread', 'Auto Join Thread', 'Whether or not to join you to the thread. Selecting no will not notify you of messages sent!', true); const autoJoinLabel = createCheckbox('auto-join-thread', 'Auto Join Thread', 'Whether or not to automatically add you to the thread.', true);
modal.addLabelComponents(titleLabel, initialMessageLabel, autoJoinLabel); modal.addLabelComponents(titleLabel, initialMessageLabel, autoJoinLabel);
interaction.showModal(modal); interaction.showModal(modal);
} }