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

@ -23,4 +23,4 @@ module.exports = class ReferencesCompleter extends Autocompleter {
}),
);
}
};
};

View File

@ -47,4 +47,4 @@ module.exports = class TagCompleter extends Autocompleter {
})),
);
}
};
};

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

@ -72,4 +72,4 @@ module.exports = class PinMessageCommand extends MessageCommand {
],
});
}
};
};

View File

@ -141,4 +141,4 @@ module.exports = class AddSlashCommand extends SlashCommand {
});
}
};
};

View File

@ -23,4 +23,4 @@ module.exports = class ClaimSlashCommand extends SlashCommand {
await interaction.deferReply({ ephemeral: false });
await client.tickets.claim(interaction);
}
};
};

View File

@ -34,4 +34,4 @@ module.exports = class CloseSlashCommand extends SlashCommand {
const client = this.client;
await client.tickets.beforeRequestClose(interaction);
}
};
};

View File

@ -76,4 +76,4 @@ module.exports = class ClaimSlashCommand extends SlashCommand {
],
});
}
};
};

View File

@ -35,4 +35,4 @@ module.exports = class NewSlashCommand extends SlashCommand {
async run(interaction) {
await useGuild(this.client, interaction, { referencesTicketId: interaction.options.getString('references', false) });
}
};
};

View File

@ -23,4 +23,4 @@ module.exports = class ReleaseSlashCommand extends SlashCommand {
await interaction.deferReply({ ephemeral: false });
await client.tickets.release(interaction);
}
};
};

View File

@ -140,4 +140,4 @@ module.exports = class RemoveSlashCommand extends SlashCommand {
userId: interaction.user.id,
});
}
};
};

View File

@ -57,4 +57,4 @@ module.exports = class TagSlashCommand extends SlashCommand {
],
});
}
};
};

View File

@ -81,4 +81,4 @@ module.exports = class TopicSlashCommand extends SlashCommand {
),
);
}
};
};

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}`)),