Fix some more eslint errors (not yet complete)
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 3d1901b..31df394 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -2,14 +2,14 @@
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 Discord, { CommandInteraction, GuildChannel, Interaction, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
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 { modalInteractionCollector } from "../../utils/dualCollector.js";
+import {GuildConfig} from "../../utils/database.js";
const command = (builder: SlashCommandSubcommandBuilder) => builder
.setName("tickets")
@@ -20,9 +20,8 @@
.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));
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- let m;
- m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+ let 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"),
@@ -33,9 +32,9 @@
if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
options.enabled = options.enabled === "yes" ? true : false;
if (options.category) {
- let channel;
+ let channel: GuildChannel;
try {
- channel = interaction.guild.channels.cache.get(options.category.id);
+ channel = await interaction.guild.channels.fetch(options.category.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -66,10 +65,10 @@
]
});
}
- let role;
+ let role: Role;
if (options.supportping) {
try {
- role = interaction.guild.roles.cache.get(options.supportping.id);
+ role = await interaction.guild.roles.fetch(options.supportping.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -136,9 +135,9 @@
}
}
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((value: string, index: number, array: string[]) => array.indexOf(value) === index);
let lastClicked = "";
- let embed;
+ let embed: EmojiEmbed;
data = {
enabled: data.tickets.enabled,
category: data.tickets.category,
@@ -200,30 +199,30 @@
.setCustomId("send")
])]
});
- let i;
+ let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000 });
+ i = await (m as Message).awaitMessageComponent({ time: 300000 });
} catch (e) { break; }
i.deferUpdate();
- if (i.component.customId === "clearCategory") {
+ if ((i.component as MessageActionRowComponent).customId === "clearCategory") {
if (lastClicked === "cat") {
lastClicked = "";
await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"]);
data.category = undefined;
} else lastClicked = "cat";
- } else if (i.component.customId === "clearMaxTickets") {
+ } else if ((i.component as MessageActionRowComponent).customId === "clearMaxTickets") {
if (lastClicked === "max") {
lastClicked = "";
await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"]);
data.maxTickets = 5;
} else lastClicked = "max";
- } else if (i.component.customId === "clearSupportPing") {
+ } else if ((i.component as MessageActionRowComponent).customId === "clearSupportPing") {
if (lastClicked === "sup") {
lastClicked = "";
await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"]);
data.supportRole = undefined;
} else lastClicked = "sup";
- } else if (i.component.customId === "send") {
+ } else if ((i.component as MessageActionRowComponent).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"},
@@ -260,15 +259,15 @@
.setStyle("PRIMARY")
])
]});
- let i;
+ let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
+ i = await (m as Message).awaitMessageComponent({time: 300000});
} catch(e) { break; }
- if (i.component.customId === "template") {
+ if ((i.component as MessageActionRowComponent).customId === "template") {
i.deferUpdate();
await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(ticketMessages[parseInt(i.values[0])].label)
- .setDescription(ticketMessages[parseInt(i.values[0])].description)
+ .setTitle(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
+ .setDescription(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
], components: [new MessageActionRow().addComponents([new MessageButton()
@@ -278,7 +277,7 @@
.setCustomId("createticket")
])]});
break;
- } else if (i.component.customId === "blank") {
+ } else if ((i.component as MessageActionRowComponent).customId === "blank") {
i.deferUpdate();
await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
.setLabel("Create Ticket")
@@ -287,7 +286,7 @@
.setCustomId("createticket")
])]});
break;
- } else if (i.component.customId === "custom") {
+ } else if ((i.component as MessageActionRowComponent).customId === "custom") {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("title")
@@ -339,11 +338,11 @@
} else { continue; }
}
}
- } else if (i.component.customId === "enabled") {
+ } else if ((i.component as MessageActionRowComponent).customId === "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 if ((i.component as MessageActionRowComponent).customId === "manageTypes") {
+ data = await manageTypes(interaction, data, m as Message);
} else {
break;
}
@@ -351,7 +350,7 @@
await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
};
-async function manageTypes(interaction, data, m) {
+async function manageTypes(interaction: Interaction, data: GuildConfig["tickets"], m: Message) {
while (true) {
if (data.useCustom) {
const customTypes = data.customTypes;
@@ -519,7 +518,7 @@
}
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
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;
@@ -527,4 +526,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index c100d05..d846511 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,10 +1,9 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Emoji, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
+import Discord, { CommandInteraction, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import { Embed, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import client from "../../utils/client.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
@@ -14,13 +13,12 @@
.setDescription("Manage the role given after typing /verify")
.addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false));
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- let m;
- m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+ const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getRole("role")) {
- let role;
+ let role: Role;
try {
- role = interaction.options.getRole("role");
+ role = interaction.options.getRole("role") as Role;
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
@@ -109,19 +107,19 @@
.setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("PRIMARY")
])]});
- let i;
+ let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
+ i = await (m as Message).awaitMessageComponent({time: 300000});
} catch(e) { break; }
i.deferUpdate();
- if (i.component.customId === "clear") {
+ if ((i.component as MessageActionRowComponent).customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
role = undefined;
}
- } else if (i.component.customId === "send") {
+ } else if ((i.component as MessageActionRowComponent).customId === "send") {
const verifyMessages = [
{label: "Verify", description: "Click the button below to get verified"},
{label: "Get verified", description: "To get access to the rest of the server, click the button below"},
@@ -157,15 +155,15 @@
.setStyle("PRIMARY")
])
]});
- let i;
+ let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
+ i = await (m as Message).awaitMessageComponent({time: 300000});
} catch(e) { break; }
- if (i.component.customId === "template") {
+ if ((i.component as MessageActionRowComponent).customId === "template") {
i.deferUpdate();
await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(verifyMessages[parseInt(i.values[0])].label)
- .setDescription(verifyMessages[parseInt(i.values[0])].description)
+ .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
+ .setDescription(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
.setStatus("Success")
.setEmoji("CONTROL.BLOCKTICK")
], components: [new MessageActionRow().addComponents([new MessageButton()
@@ -175,7 +173,7 @@
.setCustomId("verifybutton")
])]});
break;
- } else if (i.component.customId === "blank") {
+ } else if ((i.component as MessageActionRowComponent).customId === "blank") {
i.deferUpdate();
await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
.setLabel("Verify")
@@ -184,7 +182,7 @@
.setCustomId("verifybutton")
])]});
break;
- } else if (i.component.customId === "custom") {
+ } else if ((i.component as MessageActionRowComponent).customId === "custom") {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("title")
@@ -241,10 +239,10 @@
break;
}
}
- await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
+ await interaction.editReply({embeds: [(m.embeds[0] as Embed).setFooter({text: "Message closed"})], components: []});
};
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
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;
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 34ac292..f22f409 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -1,7 +1,6 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, { Channel, CommandInteraction, Message, MessageActionRow, MessageButton, MessageComponentInteraction, Role } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -20,17 +19,17 @@
ChannelType.GuildText, ChannelType.GuildNews
]));
-const callback = async (interaction: CommandInteraction): Promise<any> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
- let m;
+ let m: Message;
if (interaction.options.getRole("role") || interaction.options.getChannel("channel") || interaction.options.getString("message")) {
- let role;
- let ping;
+ let role: Role;
+ let ping: Role;
const message = interaction.options.getString("message");
try {
- role = interaction.options.getRole("role");
- ping = interaction.options.getRole("ping");
+ role = interaction.options.getRole("role") as Role;
+ ping = interaction.options.getRole("ping") as Role;
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
@@ -39,9 +38,9 @@
.setStatus("Danger")
]});
}
- let channel;
+ let channel: Channel;
try {
- channel = interaction.options.getChannel("channel");
+ channel = interaction.options.getChannel("channel") as Channel;
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
@@ -160,8 +159,8 @@
.setDisabled(config.welcome.channel == "dm")
.setStyle("SECONDARY")
])
- ]});
- let i;
+ ]}) as Message;
+ let i: MessageComponentInteraction;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
@@ -196,7 +195,7 @@
await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
};
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
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;
@@ -204,4 +203,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };