feat: transcript button in DM

This commit is contained in:
Isaac 2025-02-12 21:28:50 +00:00
parent 54455c316e
commit e947c9589b
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 29 additions and 4 deletions

View File

@ -48,8 +48,11 @@ module.exports = class TranscriptSlashCommand extends SlashCommand {
} }
shouldAllowAccess(interaction, ticket) { shouldAllowAccess(interaction, ticket) {
if (interaction.guild.id !== ticket.guildId) return false; // the creator can always get their ticket, even from outside the guild
if (ticket.createdById === interaction.member.id) return true; if (ticket.createdById === interaction.user.id) return true; // user not member (DMs)
// everyone else must be in the guild
if (interaction.guild?.id !== ticket.guildId) return false;
// and have authority
if (interaction.client.supers.includes(interaction.member.id)) return true; if (interaction.client.supers.includes(interaction.member.id)) return true;
if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return true; if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageGuild)) return true;
if (interaction.member.roles.cache.filter(role => ticket.category.staffRoles.includes(role.id)).size > 0) return true; if (interaction.member.roles.cache.filter(role => ticket.category.staffRoles.includes(role.id)).size > 0) return true;

View File

@ -1342,9 +1342,31 @@ module.exports = class TicketManager {
}); });
} }
if (ticket.guild.archive) embed.setDescription(getMessage('dm.closed.archived', { guild: channel.guild.name })); const components = [];
await creator.send({ embeds: [embed] }); if (ticket.guild.archive) {
embed.setDescription(getMessage('dm.closed.archived', { guild: channel.guild.name }));
components.push(
new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(JSON.stringify({
action: 'transcript',
ticket: ticket.id,
}))
.setStyle(ButtonStyle.Primary)
.setEmoji(getMessage('buttons.transcript.emoji'))
.setLabel(getMessage('buttons.transcript.text')),
),
);
}
await creator.send({
components,
embeds: [embed],
});
} }
} catch (error) { } catch (error) {
this.client.log.error(error); this.client.log.error(error);