Reformat using prettier
diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index 237790e..26236d8 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -1,4 +1,10 @@
-import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, ButtonInteraction } from "discord.js";
+import Discord, {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ CommandInteraction,
+ ButtonInteraction
+} from "discord.js";
import { tickets, toHexArray } from "../../utils/calculate.js";
import client from "../../utils/client.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -32,14 +38,18 @@
});
}
let count = 0;
- const targetChannel: Discord.CategoryChannel | Discord.TextChannel = (await interaction.guild.channels.fetch(config.tickets.category))! as Discord.CategoryChannel | Discord.TextChannel;
+ const targetChannel: Discord.CategoryChannel | Discord.TextChannel = (await interaction.guild.channels.fetch(
+ config.tickets.category
+ ))! as Discord.CategoryChannel | Discord.TextChannel;
if (targetChannel.type === Discord.ChannelType.GuildCategory) {
// For channels, the topic is the user ID, then the word Active
const category = targetChannel as Discord.CategoryChannel;
category.children.cache.forEach((element) => {
if (!(element.type === Discord.ChannelType.GuildText)) return;
if (((element as Discord.TextChannel).topic ?? "").includes(`${interaction.member!.user.id}`)) {
- if (((element as Discord.TextChannel).topic ?? "").endsWith("Active")) { count++; }
+ if (((element as Discord.TextChannel).topic ?? "").endsWith("Active")) {
+ count++;
+ }
}
});
} else {
@@ -47,7 +57,9 @@
const channel = targetChannel as Discord.TextChannel;
channel.threads.cache.forEach((element: Discord.ThreadChannel) => {
if (element.name.includes(`${interaction.member!.user.id}`)) {
- if (element.name.endsWith("Active")) { count++; }
+ if (element.name.endsWith("Active")) {
+ count++;
+ }
}
});
}
@@ -88,7 +100,9 @@
}
});
for (let i = 0; i < formattedTicketTypes.length; i += 5) {
- splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5)));
+ splitFormattedTicketTypes.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))
+ );
}
const m = await interaction.reply({
embeds: [
@@ -106,7 +120,13 @@
try {
component = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
return;
@@ -131,7 +151,9 @@
}
});
for (let i = 0; i < formattedTicketTypes.length; i += 5) {
- splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5)));
+ splitFormattedTicketTypes.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))
+ );
}
component.update({
embeds: [
@@ -252,11 +274,12 @@
});
}
} else {
- c = await targetChannel.threads.create({name: `${interaction.member!.user.username} - ${interaction.member!.user.id} - Active`,
- autoArchiveDuration: 60 * 24 * 7,
- type: Discord.ChannelType.PrivateThread,
- reason: "Creating ticket"
- }) as Discord.PrivateThreadChannel;
+ c = (await targetChannel.threads.create({
+ name: `${interaction.member!.user.username} - ${interaction.member!.user.id} - Active`,
+ autoArchiveDuration: 60 * 24 * 7,
+ type: Discord.ChannelType.PrivateThread,
+ reason: "Creating ticket"
+ })) as Discord.PrivateThreadChannel;
c.members.add(interaction.member!.user.id);
try {
await c.send({
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index 990b360..1c1e464 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -1,10 +1,18 @@
-import { getCommandMentionByName } from '../../utils/getCommandDataByName.js';
-import Discord, { ActionRowBuilder, ButtonBuilder, ButtonInteraction, PrivateThreadChannel, TextChannel, ButtonStyle, CategoryChannel } from "discord.js";
+import { getCommandMentionByName } from "../../utils/getCommandDataByName.js";
+import Discord, {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonInteraction,
+ PrivateThreadChannel,
+ TextChannel,
+ ButtonStyle,
+ CategoryChannel
+} from "discord.js";
import client from "../../utils/client.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import { preloadPage } from '../../utils/createTemporaryStorage.js';
-import { LoadingEmbed } from '../../utils/defaults.js';
+import { preloadPage } from "../../utils/createTemporaryStorage.js";
+import { LoadingEmbed } from "../../utils/defaults.js";
export default async function (interaction: Discord.CommandInteraction | ButtonInteraction) {
if (!interaction.guild) return;
@@ -19,7 +27,8 @@
.setDescription("This channel isn't a ticket, so you can't delete it.")
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true
+ ],
+ ephemeral: true
});
} else if (interaction.channel!.parent!.id !== ticketChannel) {
return await interaction.reply({
@@ -29,16 +38,23 @@
.setDescription("This channel isn't a ticket, so you can't delete it.")
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true
+ ],
+ ephemeral: true
});
}
const channel: PrivateThreadChannel | TextChannel = interaction.channel as PrivateThreadChannel | TextChannel;
- let status: string | null = ("topic" in interaction.channel) ? interaction.channel!.topic : interaction.channel.name;
+ let status: string | null = "topic" in interaction.channel ? interaction.channel!.topic : interaction.channel.name;
status = status ?? "";
- if (status.endsWith("Archived")) { status = "Archived"; }
- else { status = "Active"; }
+ if (status.endsWith("Archived")) {
+ status = "Archived";
+ } else {
+ status = "Active";
+ }
- const uID = channel.type === Discord.ChannelType.PrivateThread ? channel.name.split(" - ")[1] : channel.topic!.split(" ")[0];
+ const uID =
+ channel.type === Discord.ChannelType.PrivateThread
+ ? channel.name.split(" - ")[1]
+ : channel.topic!.split(" ")[0];
if (status === "Archived") {
// Delete the ticket
@@ -53,10 +69,7 @@
timestamp: Date.now()
},
list: {
- ticketFor: entry(
- uID!,
- renderUser((await interaction.guild.members.fetch(uID!)).user)
- ),
+ ticketFor: entry(uID!, renderUser((await interaction.guild.members.fetch(uID!)).user)),
closedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
closed: entry(Date.now(), renderDelta(Date.now())),
ticketChannel: entry(channel.id, channel.name)
@@ -69,26 +82,33 @@
await channel.delete();
} else if (status === "Active") {
- await interaction.reply({embeds: LoadingEmbed, fetchReply: true});
+ await interaction.reply({ embeds: LoadingEmbed, fetchReply: true });
// Archive the ticket
- await interaction.channel.fetch()
+ await interaction.channel.fetch();
if (channel.isThread()) {
channel.setName(`${channel.name.replace("Active", "Archived")}`);
channel.members.remove(channel.name.split(" - ")[1]!);
} else {
channel.setTopic(`${(channel.topic ?? "").replace("Active", "Archived")}`);
- if (!channel.topic!.includes("Archived")) { channel.setTopic("0 Archived"); }
+ if (!channel.topic!.includes("Archived")) {
+ channel.setTopic("0 Archived");
+ }
await channel.permissionOverwrites.delete(channel.topic!.split(" ")[0]!);
}
- preloadPage(interaction.channel.id, "privacy", "2")
+ preloadPage(interaction.channel.id, "privacy", "2");
const hasPremium = await client.database.premium.hasPremium(interaction.guild.id);
await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Archived Ticket")
- .setDescription(`This ticket has been Archived. Type ${getCommandMentionByName("ticket/close")} to delete it.\n` +
- hasPremium ? ("Creating a transcript will delete all messages in this ticket" +
- `\n\nFor more info on transcripts, check ${getCommandMentionByName("privacy")}`): "")
+ .setDescription(
+ `This ticket has been Archived. Type ${getCommandMentionByName(
+ "ticket/close"
+ )} to delete it.\n` + hasPremium
+ ? "Creating a transcript will delete all messages in this ticket" +
+ `\n\nFor more info on transcripts, check ${getCommandMentionByName("privacy")}`
+ : ""
+ )
.setStatus("Warning")
.setEmoji("GUILD.TICKET.ARCHIVED")
],
@@ -103,12 +123,12 @@
].concat(
hasPremium
? [
- new ButtonBuilder()
- .setLabel("Create Transcript and Delete")
- .setStyle(ButtonStyle.Primary)
- .setCustomId("createtranscript")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ]
+ new ButtonBuilder()
+ .setLabel("Create Transcript and Delete")
+ .setStyle(ButtonStyle.Primary)
+ .setCustomId("createtranscript")
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+ ]
: []
)
)
@@ -124,10 +144,7 @@
timestamp: Date.now()
},
list: {
- ticketFor: entry(
- uID!,
- renderUser((await interaction.guild.members.fetch(uID!)).user)
- ),
+ ticketFor: entry(uID!, renderUser((await interaction.guild.members.fetch(uID!)).user)),
archivedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
archived: entry(Date.now(), renderDelta(Date.now())),
ticketChannel: entry(channel.id, renderChannel(channel))
@@ -141,12 +158,13 @@
return;
}
-
async function purgeByUser(member: string, guild: string) {
const config = await client.database.guilds.read(guild);
const fetchedGuild = await client.guilds.fetch(guild);
if (!config.tickets.category) return;
- const tickets: CategoryChannel | TextChannel | undefined = fetchedGuild.channels.cache.get(config.tickets.category) as CategoryChannel | TextChannel | undefined;
+ const tickets: CategoryChannel | TextChannel | undefined = fetchedGuild.channels.cache.get(
+ config.tickets.category
+ ) as CategoryChannel | TextChannel | undefined;
if (!tickets) return;
let deleted = 0;
if (tickets.type === Discord.ChannelType.GuildCategory) {
@@ -154,7 +172,7 @@
const category = tickets as Discord.CategoryChannel;
category.children.cache.forEach((element) => {
if (!(element.type === Discord.ChannelType.GuildText)) return;
- if (!(((element as Discord.TextChannel).topic ?? "").includes(member))) return;
+ if (!((element as Discord.TextChannel).topic ?? "").includes(member)) return;
try {
element.delete();
deleted++;
@@ -175,7 +193,7 @@
}
});
}
- if (!deleted) return
+ if (!deleted) return;
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {