diff --git a/src/buttons/claimTicket.ts b/src/buttons/claimTicket.ts index a6d881a..1ba443f 100644 --- a/src/buttons/claimTicket.ts +++ b/src/buttons/claimTicket.ts @@ -11,13 +11,13 @@ class ClaimTicketButton implements Button { try { const channel = await context.channels.fetch(interaction.channelId); - + if (!channel) throw new Error("The interaction channel couldn't be fetched."); if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.'); if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel."); const settings = await Database.getOrCreateSettings(interaction.guildId); - if (!settings.private_help_role_id) throw new Error("\`private_help_role_id\` hasn't been configured. Please report this error to staff."); + if (!settings.private_help_role_id) throw new Error("`private_help_role_id` hasn't been configured. Please report this error to staff."); const guild = await context.guilds.fetch(interaction.guildId); const member = await guild.members.fetch(interaction.user.id); diff --git a/src/buttons/closeModTicket.ts b/src/buttons/closeModTicket.ts index e1acaeb..05e7b87 100644 --- a/src/buttons/closeModTicket.ts +++ b/src/buttons/closeModTicket.ts @@ -10,22 +10,22 @@ class CloseModTicketButton implements Button { try { const channel = await context.channels.fetch(interaction.channelId); - + if (!channel) throw new Error("The interaction channel couldn't be fetched."); if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.'); if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel."); - + if (!interaction.memberPermissions.has('KickMembers')) throw new Error("You don't have permission to close this ticket."); - + await interaction.message.edit({ content: interaction.message.content, components: [] }); - + await channel.send('This ticket has been closed by staff.'); - + await interaction.editReply({ content: 'Ticket closed.' }); - + await channel.edit({ archived: true, locked: true diff --git a/src/buttons/closeTicket.ts b/src/buttons/closeTicket.ts index b4962b0..8d38def 100644 --- a/src/buttons/closeTicket.ts +++ b/src/buttons/closeTicket.ts @@ -11,7 +11,7 @@ class CloseTicketButton implements Button { try { const channel = await context.channels.fetch(interaction.channelId); - + if (!channel) throw new Error("The interaction channel couldn't be fetched."); if (!channel.isThread() || channel.type != ChannelType.PrivateThread) throw new Error('This interaction was not run in a ticket thread.'); if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel."); diff --git a/src/buttons/index.ts b/src/buttons/index.ts index 10f0b34..98a6def 100644 --- a/src/buttons/index.ts +++ b/src/buttons/index.ts @@ -1,15 +1,15 @@ -import claimTicket from "./claimTicket"; -import closeModTicket from "./closeModTicket"; -import closeTicket from "./closeTicket"; -import devWatch from "./devWatch"; -import noteNext from "./noteNext"; -import notePrevious from "./notePrevious"; -import openTicketForReportedMessage from "./openTicketForReportedMessage"; -import privateHelp from "./privateHelp"; -import recordsNext from "./recordsNext"; -import recordsPrevious from "./recordsPrevious"; -import roleButton from "./roleButton"; -import unclaimTicket from "./unclaimTicket"; +import claimTicket from './claimTicket'; +import closeModTicket from './closeModTicket'; +import closeTicket from './closeTicket'; +import devWatch from './devWatch'; +import noteNext from './noteNext'; +import notePrevious from './notePrevious'; +import openTicketForReportedMessage from './openTicketForReportedMessage'; +import privateHelp from './privateHelp'; +import recordsNext from './recordsNext'; +import recordsPrevious from './recordsPrevious'; +import roleButton from './roleButton'; +import unclaimTicket from './unclaimTicket'; export default [ claimTicket, diff --git a/src/buttons/unclaimTicket.ts b/src/buttons/unclaimTicket.ts index ac2368e..af1ba10 100644 --- a/src/buttons/unclaimTicket.ts +++ b/src/buttons/unclaimTicket.ts @@ -7,7 +7,7 @@ class UnclaimTicketButton implements Button { async execute(context: Client, interaction: ButtonInteraction): Promise { if (!interaction.inGuild()) return; - await interaction.deferReply(); + await interaction.deferReply({ flags: MessageFlags.Ephemeral }); try { const channel = await context.channels.fetch(interaction.channelId); @@ -17,13 +17,13 @@ class UnclaimTicketButton implements Button { if (!channel.isSendable()) throw new Error("I don't have permission to send messages in this channel."); const settings = await Database.getOrCreateSettings(interaction.guildId); - if (!settings.private_help_role_id) throw new Error("\`private_help_role_id\` hasn't been configured. Please report this error to staff."); + if (!settings.private_help_role_id) throw new Error("`private_help_role_id` hasn't been configured. Please report this error to staff."); const guild = await context.guilds.fetch(interaction.guildId); const member = await guild.members.fetch(interaction.user.id); if (!member.roles.cache.has(settings.private_help_role_id)) throw new Error("You don't have permission to claim tickets."); - if (!interaction.message.content.split('\n').at(-1)!.includes(`<@${interaction.user.id}>`)) throw new Error(`You haven't claimed this ticket.`); + if (!interaction.message.content.split('\n').at(-1)!.includes(`<@${interaction.user.id}>`)) throw new Error('You haven\'t claimed this ticket.'); const closeButton = new ButtonBuilder() .setCustomId('close-ticket') diff --git a/src/types/button.d.ts b/src/types/button.d.ts index eff6569..bf0a363 100644 --- a/src/types/button.d.ts +++ b/src/types/button.d.ts @@ -1,4 +1,4 @@ -import { ButtonInteraction } from "discord.js"; +import { ButtonInteraction } from 'discord.js'; export interface Button { id: string;