feat: ephemeral replies on (un)claim buttons (#580)

* new lines

* ephemeral button interactions

* send message to channel if interaction is ephemeral

* move deferreply to use ephemeral on no perms

* .editReply() -> .reply()
This commit is contained in:
ari 2025-02-08 18:23:44 +01:00 committed by GitHub
parent e53c064bf7
commit b3a2bb00a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 22 additions and 18 deletions

View File

@ -16,7 +16,6 @@ module.exports = class ClaimButton extends Button {
/** @type {import("client")} */
const client = this.client;
await interaction.deferReply({ ephemeral: false });
await client.tickets.claim(interaction);
}
};

View File

@ -16,7 +16,6 @@ module.exports = class UnclaimButton extends Button {
/** @type {import("client")} */
const client = this.client;
await interaction.deferReply({ ephemeral: false });
await client.tickets.release(interaction);
}
};

View File

@ -778,7 +778,7 @@ module.exports = class TicketManager {
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
return await interaction.editReply({
return await interaction.reply({
embeds: [
new ExtendedEmbedBuilder({
iconURL: interaction.guild.iconURL(),
@ -788,9 +788,12 @@ module.exports = class TicketManager {
.setTitle(getMessage('commands.slash.claim.not_staff.title'))
.setDescription(getMessage('commands.slash.claim.not_staff.description')),
],
ephemeral: true,
});
}
await interaction.deferReply({ ephemeral: false });
await Promise.all([
interaction.channel.permissionOverwrites.edit(interaction.user, { 'ViewChannel': true }, `Ticket claimed by ${interaction.user.tag}`),
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': false }, `Ticket claimed by ${interaction.user.tag}`)),
@ -878,7 +881,7 @@ module.exports = class TicketManager {
const getMessage = this.client.i18n.getLocale(ticket.guild.locale);
if (!(await isStaff(interaction.guild, interaction.user.id))) { // if user is not staff
return await interaction.editReply({
return await interaction.reply({
embeds: [
new ExtendedEmbedBuilder({
iconURL: interaction.guild.iconURL(),
@ -888,9 +891,12 @@ module.exports = class TicketManager {
.setTitle(getMessage('commands.slash.claim.not_staff.title'))
.setDescription(getMessage('commands.slash.claim.not_staff.description')),
],
ephemeral: true,
});
}
await interaction.deferReply({ ephemeral: false });
await Promise.all([
interaction.channel.permissionOverwrites.delete(interaction.user, `Ticket released by ${interaction.user.tag}`),
...ticket.category.staffRoles.map(role => interaction.channel.permissionOverwrites.edit(role, { 'ViewChannel': true }, `Ticket released by ${interaction.user.tag}`)),