Skip to content

Commit

Permalink
feat: transcript button in log channel
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed Nov 9, 2024
1 parent 412c65c commit 2a96858
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/buttons/transcript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { Button } = require('@eartharoid/dbf');

module.exports = class ClaimButton extends Button {
constructor(client, options) {
super(client, {
...options,
id: 'transcript',
});
}

/**
* @param {*} id
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async run(id, interaction) {
/** @type {import("client")} */
const client = this.client;

const cmd = client.commands.commands.slash.get('transcript');
return await cmd.run(interaction, id.ticket);
}
};
4 changes: 2 additions & 2 deletions src/commands/slash/transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ module.exports = class TranscriptSlashCommand extends SlashCommand {
/**
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async run(interaction) {
async run(interaction, ticketId) {
/** @type {import("client")} */
const client = this.client;

await interaction.deferReply({ ephemeral: true });
const ticketId = interaction.options.getString('ticket', true);
ticketId = ticketId || interaction.options.getString('ticket', true);
const ticket = await client.prisma.ticket.findUnique({
include: {
archivedChannels: true,
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ buttons:
unclaim:
emoji: ♻️
text: Release
transcript:
emoji: 📄
text: Transcript
commands:
message:
create:
Expand Down
22 changes: 21 additions & 1 deletion src/lib/logging.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
cleanCodeBlockContent,
EmbedBuilder,
} = require('discord.js');
Expand Down Expand Up @@ -182,7 +185,24 @@ async function logTicketEvent(client, {
);
}

return await channel.send({ embeds });
return await channel.send({
components:
action === 'close' ? [
new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(JSON.stringify({
action: 'transcript',
ticket: target.id,
}))
.setStyle(ButtonStyle.Primary)
.setEmoji(getMessage('buttons.transcript.emoji'))
.setLabel(getMessage('buttons.transcript.text')),

),
] : [],
embeds,
});
}

/**
Expand Down

0 comments on commit 2a96858

Please sign in to comment.