Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 8ebcf30..3d1901b 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,14 +1,14 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { ChannelType } from 'discord-api-types';
+import { ChannelType } from "discord-api-types";
import client from "../../utils/client.js";
import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
-import { capitalize } from '../../utils/generateKeyValueList.js';
+import { capitalize } from "../../utils/generateKeyValueList.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
const command = (builder: SlashCommandSubcommandBuilder) => builder
@@ -18,24 +18,24 @@
.addChoices([["Yes", "yes"], ["No", "no"]]))
.addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
.addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default: 5").setRequired(false).setMinValue(1))
- .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false))
+ .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false));
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
- m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
- let options = {
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ const options = {
enabled: interaction.options.getString("enabled") as string | boolean,
category: interaction.options.getChannel("category"),
maxtickets: interaction.options.getNumber("maxticketsperuser"),
supportping: interaction.options.getRole("supportrole")
- }
- console.log(m)
+ };
+ console.log(m);
if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
options.enabled = options.enabled === "yes" ? true : false;
if (options.category) {
- let channel
+ let channel;
try {
- channel = interaction.guild.channels.cache.get(options.category.id)
+ channel = interaction.guild.channels.cache.get(options.category.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -44,13 +44,13 @@
.setDescription("The channel you provided is not a valid category")
.setStatus("Danger")
]
- })
+ });
}
- channel = channel as Discord.CategoryChannel
+ channel = channel as Discord.CategoryChannel;
if (channel.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Category")
- .setDescription(`You must choose a category in this server`)
+ .setDescription("You must choose a category in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -60,16 +60,16 @@
if (options.maxtickets < 1) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Max Tickets")
- .setDescription(`You must choose a number greater than 0`)
+ .setDescription("You must choose a number greater than 0")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
});
}
- let role
+ let role;
if (options.supportping) {
try {
- role = interaction.guild.roles.cache.get(options.supportping.id)
+ role = interaction.guild.roles.cache.get(options.supportping.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -78,20 +78,20 @@
.setDescription("The role you provided is not a valid role")
.setStatus("Danger")
]
- })
+ });
}
- role = role as Discord.Role
+ role = role as Discord.Role;
if (role.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Support Ping")
- .setDescription(`You must choose a role in this server`)
+ .setDescription("You must choose a role in this server")
.setStatus("Danger")
.setEmoji("GUILD.ROLE.DELETE")
]
});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.TICKET.ARCHIVED")
.setTitle("Tickets")
.setDescription(
@@ -99,26 +99,26 @@
(options.maxtickets ? `**Max Tickets:** ${options.maxtickets}\n` : "") +
(options.supportping ? `**Support Ping:** ${options.supportping.name}\n` : "") +
(options.enabled !== null ? `**Enabled:** ${options.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- }\n` : "") +
- `\nAre you sure you want to apply these settings?`
+ }\n` : "") +
+ "\nAre you sure you want to apply these settings?"
)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
- let toUpdate = {}
- if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled
- if (options.category) toUpdate["tickets.category"] = options.category.id
- if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets
- if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id
+ const toUpdate = {};
+ if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled;
+ if (options.category) toUpdate["tickets.category"] = options.category.id;
+ if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets;
+ if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id;
try {
- await client.database.guilds.write(interaction.guild.id, toUpdate)
+ await client.database.guilds.write(interaction.guild.id, toUpdate);
} catch (e) {
return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets")
- .setDescription(`Something went wrong and the staff notifications channel could not be set`)
+ .setDescription("Something went wrong and the staff notifications channel could not be set")
.setStatus("Danger")
.setEmoji("GUILD.TICKET.DELETE")
], components: []
@@ -128,7 +128,7 @@
return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
], components: []
@@ -136,7 +136,7 @@
}
}
let data = await client.database.guilds.read(interaction.guild.id);
- data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i)
+ data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i);
let lastClicked = "";
let embed;
data = {
@@ -147,7 +147,7 @@
useCustom: data.tickets.useCustom,
types: data.tickets.types,
customTypes: data.tickets.customTypes
- }
+ };
while (true) {
embed = new EmojiEmbed()
.setTitle("Tickets")
@@ -161,7 +161,7 @@
`${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
)
.setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
+ .setEmoji("GUILD.TICKET.OPEN");
m = await interaction.editReply({
embeds: [embed], components: [new MessageActionRow().addComponents([
new MessageButton()
@@ -186,7 +186,7 @@
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearSupportPing")
- .setDisabled(data.supportRole === null),
+ .setDisabled(data.supportRole === null)
]), new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Manage types")
@@ -197,40 +197,40 @@
.setLabel("Add create ticket button")
.setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("PRIMARY")
- .setCustomId("send"),
+ .setCustomId("send")
])]
});
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break }
- i.deferUpdate()
+ } catch (e) { break; }
+ i.deferUpdate();
if (i.component.customId === "clearCategory") {
if (lastClicked === "cat") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"]);
data.category = undefined;
} else lastClicked = "cat";
} else if (i.component.customId === "clearMaxTickets") {
if (lastClicked === "max") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"]);
data.maxTickets = 5;
} else lastClicked = "max";
} else if (i.component.customId === "clearSupportPing") {
if (lastClicked === "sup") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"]);
data.supportRole = undefined;
} else lastClicked = "sup";
} else if (i.component.customId === "send") {
const ticketMessages = [
{label: "Create ticket", description: "Click the button below to create a ticket"},
{label: "Issues, questions or feedback?", description: "Click below to open a ticket and get help from our staff team"},
- {label: "Contact Us", description: "Click the button below to speak to us privately"},
- ]
+ {label: "Contact Us", description: "Click the button below to speak to us privately"}
+ ];
while (true) {
- let enabled = data.enabled && data.category !== null;
+ const enabled = data.enabled && data.category !== null;
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Ticket Button")
.setDescription("Select a message template to send in this channel")
@@ -240,8 +240,8 @@
], components: [
new MessageActionRow().addComponents([
new MessageSelectMenu().setOptions(ticketMessages.map((t: {label: string, description: string, value?: string}, index) => {
- t.value = index.toString(); return t as {value: string, label: string, description: string}
- })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template"),
+ t.value = index.toString(); return t as {value: string, label: string, description: string};
+ })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
]),
new MessageActionRow().addComponents([
new MessageButton()
@@ -263,9 +263,9 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
+ } catch(e) { break; }
if (i.component.customId === "template") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(ticketMessages[parseInt(i.values[0])].label)
.setDescription(ticketMessages[parseInt(i.values[0])].description)
@@ -277,18 +277,18 @@
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
+ break;
} else if (i.component.customId === "blank") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
.setLabel("Create Ticket")
.setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
+ break;
} else if (i.component.customId === "custom") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Enter embed details`).addComponents(
+ await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("title")
.setLabel("Title")
@@ -303,7 +303,7 @@
.setRequired(true)
.setStyle("PARAGRAPH")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Ticket Button")
@@ -319,11 +319,11 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
- } catch (e) { break }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
+ } catch (e) { break; }
if (out.fields) {
- let title = out.fields.getTextInputValue("title");
- let description = out.fields.getTextInputValue("description");
+ const title = out.fields.getTextInputValue("title");
+ const description = out.fields.getTextInputValue("description");
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(title)
.setDescription(description)
@@ -335,26 +335,26 @@
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
- } else { continue }
+ break;
+ } else { continue; }
}
}
} else if (i.component.customId === "enabled") {
- await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled });
data.enabled = !data.enabled;
} else if (i.component.customId === "manageTypes") {
data = await manageTypes(interaction, data, m);
} else {
- break
+ break;
}
}
await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
-}
+};
async function manageTypes(interaction, data, m) {
while (true) {
if (data.useCustom) {
- let customTypes = data.customTypes;
+ const customTypes = data.customTypes;
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -393,29 +393,29 @@
new MessageButton()
.setLabel("Switch to default types")
.setStyle("SECONDARY")
- .setCustomId("switchToDefault"),
+ .setCustomId("switchToDefault")
])
])
});
} else {
- let inUse = toHexArray(data.types, ticketTypes)
- let options = [];
+ const inUse = toHexArray(data.types, ticketTypes);
+ const options = [];
ticketTypes.forEach(type => {
options.push(new SelectMenuOption({
label: capitalize(type),
value: type,
emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")),
default: inUse.includes(type)
- }))
- })
- let selectPane = new MessageActionRow().addComponents([
+ }));
+ });
+ const selectPane = new MessageActionRow().addComponents([
new Discord.MessageSelectMenu()
.addOptions(options)
.setCustomId("types")
.setMaxValues(ticketTypes.length)
.setMinValues(1)
.setPlaceholder("Select types to use")
- ])
+ ]);
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -437,7 +437,7 @@
new MessageButton()
.setLabel("Switch to custom types")
.setStyle("SECONDARY")
- .setCustomId("switchToCustom"),
+ .setCustomId("switchToCustom")
])
]
});
@@ -445,20 +445,20 @@
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break }
+ } catch (e) { break; }
if (i.component.customId === "types") {
- i.deferUpdate()
- let types = toHexInteger(i.values, ticketTypes);
- await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
+ i.deferUpdate();
+ const types = toHexInteger(i.values, ticketTypes);
+ await client.database.guilds.write(interaction.guild.id, { "tickets.types": types });
data.types = types;
} else if (i.component.customId === "removeTypes") {
- i.deferUpdate()
- let types = i.values
+ i.deferUpdate();
+ const types = i.values;
let customTypes = data.customTypes;
if (customTypes) {
customTypes = customTypes.filter((t) => !types.includes(t));
customTypes = customTypes.length > 0 ? customTypes : null;
- await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes });
data.customTypes = customTypes;
}
} else if (i.component.customId === "addType") {
@@ -472,7 +472,7 @@
.setRequired(true)
.setStyle("SHORT")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -488,42 +488,42 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType")
- } catch (e) { continue }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType");
+ } catch (e) { continue; }
if (out.fields) {
let toAdd = out.fields.getTextInputValue("type");
- if (!toAdd) { continue }
- toAdd = toAdd.substring(0, 80)
+ if (!toAdd) { continue; }
+ toAdd = toAdd.substring(0, 80);
try {
- await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd)
- } catch { continue }
+ await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd);
+ } catch { continue; }
data.customTypes = data.customTypes || [];
if (!data.customTypes.includes(toAdd)) {
data.customTypes.push(toAdd);
}
- } else { continue }
+ } else { continue; }
} else if (i.component.customId === "switchToDefault") {
- i.deferUpdate()
- await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
+ i.deferUpdate();
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, []);
data.useCustom = false;
} else if (i.component.customId === "switchToCustom") {
- i.deferUpdate()
- await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
+ i.deferUpdate();
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, []);
data.useCustom = true;
} else {
- i.deferUpdate()
- break
+ i.deferUpdate();
+ break;
}
}
- return data
+ return data;
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };