Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 82eda6a..59ba2e6 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -6,20 +6,20 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
import createPageIndicator from "../../utils/createPageIndicator.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("about")
- .setDescription("Shows info about a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"))
+ .setName("about")
+ .setDescription("Shows info about a user")
+ .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"));
class Embed {
embed: Discord.MessageEmbed;
title: string;
- description: string = "";
- pageId: number = 0;
+ description = "";
+ pageId = 0;
setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
setTitle(title: string) { this.title = title; return this; }
setDescription(description: string) { this.description = description; return this; }
@@ -28,23 +28,23 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
- const { renderUser, renderDelta } = client.logger
- let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
- let flags: string[] = [];
+ const { renderUser, renderDelta } = client.logger;
+ const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+ const flags: string[] = [];
if ([
"438733159748599813", // Pinea
"317731855317336067", // Mini
"261900651230003201", // Coded
- "511655498676699136", // Zan
- ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER") }
- if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER") }
+ "511655498676699136" // Zan
+ ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER"); }
+ if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER"); }
member.user.flags.toArray().map(flag => {
- flags.push(flag.toString())
- })
- if (member.user.bot === true) { flags.push("BOT") }
+ flags.push(flag.toString());
+ });
+ if (member.user.bot === true) { flags.push("BOT"); }
// Check if they are boosting the server
- if (member.premiumSince) { flags.push("BOOSTER") }
- let nameReplacements = {
+ if (member.premiumSince) { flags.push("BOOSTER"); }
+ const nameReplacements = {
"NUCLEUSDEVELOPER": "**Nucleus Developer**",
"CLICKSDEVELOPER": "Clicks Developer",
"HOUSE_BRAVERY": "Hypesquad Bravery",
@@ -59,31 +59,31 @@
"EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer",
"BOT": "Bot",
"BOOSTER": "Server Booster"
- }
- let members = await interaction.guild.members.fetch()
- let membersArray = [...members.values()]
- membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp)
- let joinPos = membersArray.findIndex(m => m.id === member.user.id)
+ };
+ const members = await interaction.guild.members.fetch();
+ const membersArray = [...members.values()];
+ membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp);
+ const joinPos = membersArray.findIndex(m => m.id === member.user.id);
- let roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort()
+ const roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort();
let s = "";
let count = 0;
- let ended = false
+ let ended = false;
roles.map(item => {
if (ended) return;
- let string = `<@&${item.id}>, `
+ const string = `<@&${item.id}>, `;
if(s.length + string.length > 1000) {
- ended = true
- s += `and ${roles.size - count} more`
- return
- };
- count ++
+ ended = true;
+ s += `and ${roles.size - count} more`;
+ return;
+ }
+ count ++;
s += string;
- })
+ });
if(s.length > 0 && !ended) s = s.slice(0, -2);
- let perms = ""
- let permsArray = {
+ let perms = "";
+ const permsArray = {
"ADMINISTRATOR": "Administrator",
"MANAGE_GUILD": "Manage Server",
"MANAGE_ROLES": "Manage Roles",
@@ -96,15 +96,15 @@
"MANAGE_MESSAGES": "Manage Messages",
"VIEW_AUDIT_LOG": "View Audit Log",
"MENTION_EVERYONE": "Mention Everyone"
- }
+ };
Object.keys(permsArray).map(perm => {
- let hasPerm = member.permissions.has(perm as Discord.PermissionString)
- perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`
- })
+ const hasPerm = member.permissions.has(perm as Discord.PermissionString);
+ perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`;
+ });
let selectPaneOpen = false;
- let embeds = [
+ const embeds = [
new Embed()
.setEmbed(new EmojiEmbed()
.setTitle("User Info: General")
@@ -138,7 +138,7 @@
generateKeyValueList({
"member": renderUser(member.user),
"id": `\`${member.id}\``,
- "roles": `${member.roles.cache.size - 1}`,
+ "roles": `${member.roles.cache.size - 1}`
}) + "\n" +
(s.length > 0 ? s : "*None*") + "\n"
)
@@ -152,37 +152,37 @@
.setDescription(
generateKeyValueList({
"member": renderUser(member.user),
- "id": `\`${member.id}\``,
+ "id": `\`${member.id}\``
}) + "\n" + perms
)
.setThumbnail(await member.user.displayAvatarURL({dynamic: true}))
- ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2),
- ]
- let m
+ ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2)
+ ];
+ let m;
m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
- let page = 0
- let breakReason = ""
+ let page = 0;
+ let breakReason = "";
while (true) {
- let em = new Discord.MessageEmbed(embeds[page].embed)
+ const em = new Discord.MessageEmbed(embeds[page].embed);
em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page));
- let selectPane = []
+ let selectPane = [];
if (selectPaneOpen) {
- let options = [];
+ const options = [];
embeds.forEach(embed => {
options.push(new SelectMenuOption({
label: embed.title,
value: embed.pageId.toString(),
- description: embed.description || "",
- }))
- })
+ description: embed.description || ""
+ }));
+ });
selectPane = [new MessageActionRow().addComponents([
new Discord.MessageSelectMenu()
.addOptions(options)
.setCustomId("page")
.setMaxValues(1)
.setPlaceholder("Choose a page...")
- ])]
+ ])];
}
await interaction.editReply({
embeds: [em],
@@ -207,12 +207,12 @@
.setCustomId("close")
.setStyle("DANGER")
])])
- })
- let i
+ });
+ let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch { breakReason = "Message timed out"; break }
- i.deferUpdate()
+ } catch { breakReason = "Message timed out"; break; }
+ i.deferUpdate();
if (i.component.customId === "left") {
if (page > 0) page--;
selectPaneOpen = false;
@@ -232,7 +232,7 @@
break;
}
}
- let em = new Discord.MessageEmbed(embeds[page].embed)
+ const em = new Discord.MessageEmbed(embeds[page].embed);
em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | " + breakReason);
await interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
new MessageButton()
@@ -255,12 +255,12 @@
.setCustomId("close")
.setStyle("DANGER")
.setDisabled(true)
- ])]})
-}
+ ])]});
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index e72506f..8f327a5 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -2,19 +2,18 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("avatar")
- .setDescription("Shows the avatar of a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"))
+ .setName("avatar")
+ .setDescription("Shows the avatar of a user")
+ .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"));
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- const { renderUser } = client.logger
- let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+const callback = async (interaction: CommandInteraction): Promise<void> => {
+ const { renderUser } = client.logger;
+ const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("User Info")
.setStatus("Success")
@@ -22,16 +21,16 @@
.setDescription(
generateKeyValueList({
"member": renderUser(member.user),
- "url": member.user.displayAvatarURL({dynamic: true}),
+ "url": member.user.displayAvatarURL({dynamic: true})
})
)
.setImage(await member.user.displayAvatarURL({dynamic: true}))
], ephemeral: true, fetchReply: true});
-}
+};
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index c2e0986..48733fc 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,6 +1,8 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -9,91 +11,92 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("track")
- .setDescription("Moves a user along a role track")
- .addUserOption(option => option.setName("user").setDescription("The user to manage").setRequired(true))
+ .setName("track")
+ .setDescription("Moves a user along a role track")
+ .addUserOption(option => option.setName("user").setDescription("The user to manage").setRequired(true));
-const generateFromTrack = (position: number, active: any, size: number, disabled: any) => {
- active = active ? "ACTIVE" : "INACTIVE"
- disabled = disabled ? "GREY." : ""
- if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active
- if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active
- if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active
- return "TRACKS.VERTICAL.MIDDLE." + disabled + active
-}
+const generateFromTrack = (position: number, active: string | boolean, size: number, disabled: string | boolean) => {
+ active = active ? "ACTIVE" : "INACTIVE";
+ disabled = disabled ? "GREY." : "";
+ if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active;
+ if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
+ if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active;
+ return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
+};
-const callback = async (interaction: CommandInteraction): Promise<any> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const { renderUser } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
- let config = await client.database.guilds.read(guild.id);
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
- let track = 0
+ if (!guild) return;
+ const config = await client.database.guilds.read(guild.id);
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+ let track = 0;
let generated;
- const roles = await guild.roles.fetch()
- let memberRoles = await member.roles
- let managed
+ const roles = await guild.roles.fetch();
+ const memberRoles = await member.roles;
+ let managed: boolean;
while (true) {
- let data = config.tracks[track]
- if (data.manageableBy !== undefined) managed = data.manageableBy.some(element => {return memberRoles.cache.has(element)})
- else managed = false
- let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
- let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
+ const data = config.tracks[track];
+ if (data.manageableBy !== undefined) managed = data.manageableBy.some((element: string) => {return memberRoles.cache.has(element);});
+ else managed = false;
+ const dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
+ const hasRoleInTrack = option.track.some((element: string) => {return memberRoles.cache.has(element);});
return new SelectMenuOption({
default: index === track,
label: option.name,
value: index.toString(),
description: option.track.length === 0 ? "No" : addPlural(option.track.length, "role"),
emoji: client.emojis.resolve(getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id"))
- })
- })).setCustomId("select").setMaxValues(1)
- let allowed = []
- generated = "**Track:** " + data.name + "\n" + "**Member:** " + renderUser(member.user) + "\n"
- generated += (data.nullable ? "Members do not need a role in this track" : "A role in this track is required") + "\n"
- generated += (data.retainPrevious ? "When promoted, the user keeps previous roles" : "Members will lose their current role when promoted") + "\n"
+ });
+ })).setCustomId("select").setMaxValues(1);
+ const allowed = [];
+ generated = "**Track:** " + data.name + "\n" + "**Member:** " + renderUser(member.user) + "\n";
+ generated += (data.nullable ? "Members do not need a role in this track" : "A role in this track is required") + "\n";
+ generated += (data.retainPrevious ? "When promoted, the user keeps previous roles" : "Members will lose their current role when promoted") + "\n";
generated += "\n" + data.track.map((role, index) => {
- let allow = (roles.get(role).position >= (interaction.member as GuildMember).roles.highest.position) && !managed
- allowed.push(!allow)
+ const allow = (roles.get(role).position >= (interaction.member as GuildMember).roles.highest.position) && !managed;
+ allowed.push(!allow);
return getEmojiByName(generateFromTrack(
index,
memberRoles.cache.has(role),
data.track.length,
allow
)) + " " +
- roles.get(role).name + " [<@&" + roles.get(role).id + ">]"
- }).join("\n")
- let selected = [];
+ roles.get(role).name + " [<@&" + roles.get(role).id + ">]";
+ }).join("\n");
+ const selected = [];
for (let i = 0; i < data.track.length; i++) {
- if (memberRoles.cache.has(data.track[i])) selected.push(data.track[i])
+ if (memberRoles.cache.has(data.track[i])) selected.push(data.track[i]);
}
- let conflict = data.retainPrevious ? false : selected.length > 1;
- let conflictDropdown
- let currentRoleIndex
+ const conflict = data.retainPrevious ? false : selected.length > 1;
+ let conflictDropdown;
+ let currentRoleIndex;
if (conflict) {
- generated += `\n\n${getEmojiByName(`PUNISH.WARN.${managed ? "YELLOW" : "RED"}`)} This user has ${selected.length} roles from this track. `
- conflictDropdown = []
+ generated += `\n\n${getEmojiByName(`PUNISH.WARN.${managed ? "YELLOW" : "RED"}`)} This user has ${selected.length} roles from this track. `;
+ conflictDropdown = [];
if (
(roles.get(selected[0]).position < memberRoles.highest.position) || managed
) {
- generated += `In order to promote or demote this user, you must select which role the member should keep.`
+ generated += "In order to promote or demote this user, you must select which role the member should keep.";
selected.forEach(role => {
conflictDropdown.push(new SelectMenuOption({
label: roles.get(role).name,
- value: roles.get(role).id,
- }))
- })
+ value: roles.get(role).id
+ }));
+ });
conflictDropdown = [new Discord.MessageSelectMenu()
.addOptions(conflictDropdown)
.setCustomId("conflict")
.setMaxValues(1)
- .setPlaceholder("Select a role to keep")]
+ .setPlaceholder("Select a role to keep")];
} else {
- generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep."
+ generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep.";
}
} else {
- currentRoleIndex = selected.length === 0 ? -1 : data.track.indexOf(selected[0].toString())
+ currentRoleIndex = selected.length === 0 ? -1 : data.track.indexOf(selected[0].toString());
}
- let m = await interaction.editReply({embeds: [new EmojiEmbed()
+ const m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("TRACKS.ICON")
.setTitle("Tracks")
.setDescription(`${generated}`)
@@ -101,82 +104,82 @@
], components: [
new MessageActionRow().addComponents(dropdown)
]
- .concat(conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : [])
- .concat([
- new MessageActionRow().addComponents([
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.UP", "id"))
- .setLabel("Move up")
- .setCustomId("promote")
- .setStyle("SUCCESS")
- .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
- .setLabel("Move down")
- .setCustomId("demote")
- .setStyle("DANGER")
- .setDisabled(conflict || (
- data.nullable ? currentRoleIndex <= -1 :
- currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
- ) || !allowed[currentRoleIndex]),
- ])
- ])})
+ .concat(conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : [])
+ .concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.UP", "id"))
+ .setLabel("Move up")
+ .setCustomId("promote")
+ .setStyle("SUCCESS")
+ .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
+ .setLabel("Move down")
+ .setCustomId("demote")
+ .setStyle("DANGER")
+ .setDisabled(conflict || (
+ data.nullable ? currentRoleIndex <= -1 :
+ currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
+ ) || !allowed[currentRoleIndex])
+ ])
+ ])});
let component;
try {
component = await (m as Message).awaitMessageComponent({time: 300000});
} catch (e) {
- return
+ return;
}
- component.deferUpdate()
+ component.deferUpdate();
if (component.customId === "conflict") {
- let rolesToRemove = selected.filter(role => role !== component.values[0])
- await member.roles.remove(rolesToRemove)
+ const rolesToRemove = selected.filter(role => role !== component.values[0]);
+ await member.roles.remove(rolesToRemove);
} else if (component.customId === "promote") {
if (
currentRoleIndex === -1 ? allowed[data.track.length - 1] :
- allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
+ allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
) {
if (currentRoleIndex === -1) {
- await member.roles.add(data.track[data.track.length - 1])
+ await member.roles.add(data.track[data.track.length - 1]);
} else if (currentRoleIndex < data.track.length) {
- if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex])
- await member.roles.add(data.track[currentRoleIndex - 1])
+ if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex]);
+ await member.roles.add(data.track[currentRoleIndex - 1]);
}
}
} else if (component.customId === "demote") {
if(allowed[currentRoleIndex]) {
if (currentRoleIndex === data.track.length - 1) {
- if (data.nullable) await member.roles.remove(data.track[currentRoleIndex])
+ if (data.nullable) await member.roles.remove(data.track[currentRoleIndex]);
} else if (currentRoleIndex > -1) {
- await member.roles.remove(data.track[currentRoleIndex])
- await member.roles.add(data.track[currentRoleIndex + 1])
+ await member.roles.remove(data.track[currentRoleIndex]);
+ await member.roles.add(data.track[currentRoleIndex + 1]);
}
}
} else if (component.customId === "select") {
- track = component.values[0]
+ track = component.values[0];
}
}
-}
+};
-const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let tracks = (await client.database.guilds.read(interaction.guild.id)).tracks
- if (tracks.length === 0) throw "This server does not have any tracks"
- let member = (interaction.member as GuildMember)
+const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+ const tracks = (await client.database.guilds.read(interaction.guild.id)).tracks;
+ if (tracks.length === 0) throw "This server does not have any tracks";
+ const member = (interaction.member as GuildMember);
// Allow the owner to promote anyone
- if (member.id === interaction.guild.ownerId) return true
+ if (member.id === interaction.guild.ownerId) return true;
// Check if the user can manage any of the tracks
- let managed = false
+ let managed = false;
for (const element of tracks) {
- if (!element.track.manageableBy) continue
- if (!element.track.manageableBy.some(role => member.roles.cache.has(role))) continue
+ if (!element.track.manageableBy) continue;
+ if (!element.track.manageableBy.some(role => member.roles.cache.has(role))) continue;
managed = true;
break;
- };
+ }
// Check if the user has manage_roles permission
if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
// Allow track
return true;
-}
+};
export { command };
export { callback };