Reformat using prettier
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: {