Fix a bunch of linter errors
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index e5c017f..6509c03 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -4,31 +4,53 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
export default async function (interaction) {
- const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+ const {
+ log,
+ NucleusColors,
+ entry,
+ renderUser,
+ renderChannel,
+ renderDelta
+ } = client.logger;
const config = await client.database.guilds.read(interaction.guild.id);
let thread = false;
if (interaction.channel instanceof Discord.ThreadChannel) thread = true;
const threadChannel = interaction.channel as Discord.ThreadChannel;
- const channel = (interaction.channel as Discord.TextChannel);
- if (!channel.parent || config.tickets.category !== channel.parent.id || (thread ? (threadChannel.parent.parent.id !== config.tickets.category) : false)) {
- return interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Deleting Ticket...")
- .setDescription("This ticket is not in your tickets category, so cannot be deleted. You cannot run close in a thread.")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
+ const channel = interaction.channel as Discord.TextChannel;
+ if (
+ !channel.parent ||
+ config.tickets.category !== channel.parent.id ||
+ (thread
+ ? threadChannel.parent.parent.id !== config.tickets.category
+ : false)
+ ) {
+ return interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Deleting Ticket...")
+ .setDescription(
+ "This ticket is not in your tickets category, so cannot be deleted. You cannot run close in a thread."
+ )
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ ephemeral: true
+ });
}
const status = channel.topic.split(" ")[1];
if (status === "Archived") {
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Delete Ticket")
- .setDescription("Your ticket is being deleted...")
- .setStatus("Danger")
- .setEmoji("GUILD.TICKET.CLOSE")
- ]});
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Delete Ticket")
+ .setDescription("Your ticket is being deleted...")
+ .setStatus("Danger")
+ .setEmoji("GUILD.TICKET.CLOSE")
+ ]
+ });
const data = {
- meta:{
+ meta: {
type: "ticketDeleted",
displayName: "Ticket Deleted",
calculateType: "ticketUpdate",
@@ -37,9 +59,24 @@
timestamp: new Date().getTime()
},
list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- deletedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ ticketFor: entry(
+ channel.topic.split(" ")[0],
+ renderUser(
+ (
+ await interaction.guild.members.fetch(
+ channel.topic.split(" ")[0]
+ )
+ ).user
+ )
+ ),
+ deletedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ )
},
hidden: {
guild: interaction.guild.id
@@ -49,12 +86,15 @@
interaction.channel.delete();
return;
} else if (status === "Active") {
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("Your ticket is being closed...")
- .setStatus("Warning")
- .setEmoji("GUILD.TICKET.ARCHIVED")
- ]});
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("Your ticket is being closed...")
+ .setStatus("Warning")
+ .setEmoji("GUILD.TICKET.ARCHIVED")
+ ]
+ });
const overwrites = [
{
id: channel.topic.split(" ")[0],
@@ -69,15 +109,23 @@
] as Discord.OverwriteResolvable[];
if (config.tickets.supportRole !== null) {
overwrites.push({
- id: interaction.guild.roles.cache.get(config.tickets.supportRole),
- allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
+ id: interaction.guild.roles.cache.get(
+ config.tickets.supportRole
+ ),
+ allow: [
+ "VIEW_CHANNEL",
+ "SEND_MESSAGES",
+ "ATTACH_FILES",
+ "ADD_REACTIONS",
+ "READ_MESSAGE_HISTORY"
+ ],
type: "role"
});
}
- channel.edit({permissionOverwrites: overwrites});
+ channel.edit({ permissionOverwrites: overwrites });
channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
const data = {
- meta:{
+ meta: {
type: "ticketClosed",
displayName: "Ticket Closed",
calculateType: "ticketUpdate",
@@ -86,9 +134,24 @@
timestamp: new Date().getTime()
},
list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- closed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ ticketFor: entry(
+ channel.topic.split(" ")[0],
+ renderUser(
+ (
+ await interaction.guild.members.fetch(
+ channel.topic.split(" ")[0]
+ )
+ ).user
+ )
+ ),
+ closedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
+ closed: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
ticketChannel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -96,26 +159,43 @@
}
};
log(data);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket has been closed.\nType `/ticket close` again to delete it.\n\nNote: Check `/privacy` for details about transcripts.")
- .setStatus("Warning")
- .setEmoji("GUILD.TICKET.ARCHIVED")
- ], components: [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Delete")
- .setStyle("DANGER")
- .setCustomId("closeticket")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ].concat(client.database.premium.hasPremium(interaction.guild.id) ? [
- new MessageButton()
- .setLabel("Create Transcript and Delete")
- .setStyle("PRIMARY")
- .setCustomId("createtranscript")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ] : []))
- ]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription(
+ "This ticket has been closed.\nType `/ticket close` again to delete it.\n\nNote: Check `/privacy` for details about transcripts."
+ )
+ .setStatus("Warning")
+ .setEmoji("GUILD.TICKET.ARCHIVED")
+ ],
+ components: [
+ new MessageActionRow().addComponents(
+ [
+ new MessageButton()
+ .setLabel("Delete")
+ .setStyle("DANGER")
+ .setCustomId("closeticket")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ].concat(
+ client.database.premium.hasPremium(interaction.guild.id)
+ ? [
+ new MessageButton()
+ .setLabel("Create Transcript and Delete")
+ .setStyle("PRIMARY")
+ .setCustomId("createtranscript")
+ .setEmoji(
+ getEmojiByName(
+ "CONTROL.DOWNLOAD",
+ "id"
+ )
+ )
+ ]
+ : []
+ )
+ )
+ ]
+ });
return;
}
}
@@ -127,19 +207,22 @@
if (!tickets) return;
const ticketChannels = tickets.children;
let deleted = 0;
- ticketChannels.forEach(element => {
+ ticketChannels.forEach((element) => {
if (element.type !== "GUILD_TEXT") return;
if (element.topic.split(" ")[0] === member) {
try {
element.delete();
- } catch { /* Errors if the channel does not exist (deleted already) */ }
+ } catch {
+ /* Errors if the channel does not exist (deleted already) */
+ }
deleted++;
}
});
if (deleted) {
- const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ member.client.logger;
const data = {
- meta:{
+ meta: {
type: "ticketPurge",
displayName: "Tickets Purged",
calculateType: "ticketUpdate",
@@ -150,7 +233,10 @@
list: {
ticketFor: entry(member, renderUser(member)),
deletedBy: entry(null, "Member left server"),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
ticketsDeleted: deleted
},
hidden: {
@@ -161,4 +247,4 @@
}
}
-export { purgeByUser };
\ No newline at end of file
+export { purgeByUser };