aboutsummaryrefslogtreecommitdiff
path: root/174bg/discord-bot/utilities/createTicket.js
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-22 15:32:57 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-22 15:32:57 +0100
commit72487019b3f255cece40a8073bbad8bc9968a3b7 (patch)
treeb6590e63039cdc8b1820bd345cdfe83f28ff839b /174bg/discord-bot/utilities/createTicket.js
parentda0509c91376f56f133872eddd2e4282d76f215e (diff)
downloadunnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.gz
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.bz2
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.xz
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.zip
major code refactor, add uex lookup
Diffstat (limited to '174bg/discord-bot/utilities/createTicket.js')
-rw-r--r--174bg/discord-bot/utilities/createTicket.js55
1 files changed, 0 insertions, 55 deletions
diff --git a/174bg/discord-bot/utilities/createTicket.js b/174bg/discord-bot/utilities/createTicket.js
deleted file mode 100644
index 6289715..0000000
--- a/174bg/discord-bot/utilities/createTicket.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import { ChannelType, PermissionFlagsBits } from "discord.js";
-
-export default async (
- interaction,
- options = { roleNamesWithAccess: [], ticketNamePrefix: "ticket-" },
-) => {
- const ticketsCategory = interaction.guild.channels.cache.find(
- (channel) =>
- channel.name.toLowerCase() === "tickets" &&
- channel.type === ChannelType.GuildCategory,
- );
-
- if (!ticketsCategory)
- return await interaction.reply("Tickets category not found.");
-
- // get the roles that should have access to this ticket
- const rolesWithAccess = options.roleNamesWithAccess.map((roleName) => {
- return interaction.guild.roles.cache.find(
- (role) => role.name.toLowerCase() === roleName.toLowerCase(),
- );
- });
-
- // create a new text channel under the "tickets" category with the following format: ticket-<timestamp_short>
- const timestamp = new Date()
- .toISOString()
- .replace(/[-:.T]/g, "")
- .slice(2, 16);
-
- const channelName = `${options.ticketNamePrefix}${timestamp}`;
-
- const newChannel = await interaction.guild.channels.create({
- name: channelName,
- type: ChannelType.GuildText,
- parent: ticketsCategory.id,
- // set permissions so that only the user who created the ticket and the roles with access can view it
- permissionOverwrites: [
- {
- id: interaction.user.id,
- allow: [
- PermissionFlagsBits.ViewChannel,
- PermissionFlagsBits.SendMessages,
- ],
- },
- ...rolesWithAccess.map((role) => ({
- id: role.id,
- allow: [
- PermissionFlagsBits.ViewChannel,
- PermissionFlagsBits.SendMessages,
- ],
- })),
- ],
- });
-
- return newChannel;
-};