From d723827b91cbe59a7ccbb12942172ed00cc2006e Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Thu, 16 Jul 2026 16:43:48 +0100 Subject: replace close command with close-ticket command and update exports --- 174bg/discord-bot/commands/_index.js | 6 ++-- 174bg/discord-bot/commands/close-ticket.js | 55 ++++++++++++++++++++++++++++++ 174bg/discord-bot/commands/close.js | 55 ------------------------------ 3 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 174bg/discord-bot/commands/close-ticket.js delete mode 100644 174bg/discord-bot/commands/close.js diff --git a/174bg/discord-bot/commands/_index.js b/174bg/discord-bot/commands/_index.js index 06615dd..d1a50c6 100644 --- a/174bg/discord-bot/commands/_index.js +++ b/174bg/discord-bot/commands/_index.js @@ -1,6 +1,6 @@ import requisition from "./requisition.js"; -import close from "./close.js"; +import closeTicket from "./close-ticket.js"; -export { requisition, close }; +export { requisition, closeTicket }; -export default [requisition, close]; +export default [requisition, closeTicket]; diff --git a/174bg/discord-bot/commands/close-ticket.js b/174bg/discord-bot/commands/close-ticket.js new file mode 100644 index 0000000..ca3040e --- /dev/null +++ b/174bg/discord-bot/commands/close-ticket.js @@ -0,0 +1,55 @@ +import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"; + +export default { + data: new SlashCommandBuilder() + .setName("close-ticket") + .setDescription( + "Closes the current ticket by logging the contents and deleting the channel.", + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + execute: async (interaction) => { + const channel = interaction.channel; + + if (!channel || !channel.name.startsWith("ticket-")) { + return await interaction.reply({ + content: "This command can only be used in a ticket channel.", + ephemeral: true, + }); + } + + // log the contents of the ticket and send to the logs channel if it exists + const messages = await channel.messages.fetch({ limit: 100 }); + const log = messages + .map((message) => `${message.author.tag}: ${message.content}`) + .reverse() + .join("\n"); + + console.log(`Ticket log for ${channel.name}:\n${log}`); + + const logsChannel = interaction.guild.channels.cache.find( + (ch) => ch.name === "logs" && ch.isTextBased(), + ); + + if (logsChannel) + await logsChannel.send({ + content: `# Ticket log for ${channel.name}`, + files: [ + { + name: `${channel.name}.txt`, + attachment: Buffer.from( + messages + .map( + (message) => + `${message.author.tag}/${message.author.id}: ${message.content}`, + ) + .reverse() + .join("\n"), + ), + }, + ], + }); + + // delete the channel + await channel.delete(); + }, +}; diff --git a/174bg/discord-bot/commands/close.js b/174bg/discord-bot/commands/close.js deleted file mode 100644 index 25bdd41..0000000 --- a/174bg/discord-bot/commands/close.js +++ /dev/null @@ -1,55 +0,0 @@ -import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"; - -export default { - data: new SlashCommandBuilder() - .setName("close") - .setDescription( - "Closes the current ticket by logging the contents and deleting the channel.", - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - execute: async (interaction) => { - const channel = interaction.channel; - - if (!channel || !channel.name.startsWith("ticket-")) { - return await interaction.reply({ - content: "This command can only be used in a ticket channel.", - ephemeral: true, - }); - } - - // log the contents of the ticket and send to the logs channel if it exists - const messages = await channel.messages.fetch({ limit: 100 }); - const log = messages - .map((message) => `${message.author.tag}: ${message.content}`) - .reverse() - .join("\n"); - - console.log(`Ticket log for ${channel.name}:\n${log}`); - - const logsChannel = interaction.guild.channels.cache.find( - (ch) => ch.name === "logs" && ch.isTextBased(), - ); - - if (logsChannel) - await logsChannel.send({ - content: `# Ticket log for ${channel.name}`, - files: [ - { - name: `${channel.name}.txt`, - attachment: Buffer.from( - messages - .map( - (message) => - `${message.author.tag}/${message.author.id}: ${message.content}`, - ) - .reverse() - .join("\n"), - ), - }, - ], - }); - - // delete the channel - await channel.delete(); - }, -}; -- cgit v1.2.3