I hereby decree that this document shall no longer contain the substring " == ", and hereafter shall be referred to as " === ". This amendment shall take effect immediately.
Signed-off-by: pineafan <pineapplefanyt@gmail.com>
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 54af9d7..f6c1df1 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -15,9 +16,9 @@
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
+ 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
}
@@ -26,11 +27,7 @@
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: [new EmojiEmbed()
- .setEmoji("NUCLEUS.LOADING")
- .setTitle("Loading")
- .setStatus("Danger")
- ], ephemeral: true})
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
let track = 0
let generated;
const roles = await guild.roles.fetch()
@@ -43,10 +40,10 @@
let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
return new SelectMenuOption({
- default: index == track,
+ default: index === track,
label: option.name,
value: index.toString(),
- description: option.track.length == 0 ? "No" : addPlural(option.track.length, "role"),
+ 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)
@@ -94,7 +91,7 @@
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()
.setEmoji("TRACKS.ICON")
@@ -112,7 +109,7 @@
.setLabel("Move up")
.setCustomId("promote")
.setStyle("SUCCESS")
- .setDisabled(conflict || currentRoleIndex == 0 || (currentRoleIndex == -1 ? false : !allowed[currentRoleIndex - 1])),
+ .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
new MessageButton()
.setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
.setLabel("Move down")
@@ -120,7 +117,7 @@
.setStyle("DANGER")
.setDisabled(conflict || (
data.nullable ? currentRoleIndex <= -1 :
- currentRoleIndex == data.track.length - 1 || currentRoleIndex <= -1
+ currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
) || !allowed[currentRoleIndex]),
])
])})
@@ -131,31 +128,31 @@
return
}
component.deferUpdate()
- if (component.customId == "conflict") {
- let rolesToRemove = selected.filter(role => role != component.values[0])
+ if (component.customId === "conflict") {
+ let rolesToRemove = selected.filter(role => role !== component.values[0])
await member.roles.remove(rolesToRemove)
- } else if (component.customId == "promote") {
+ } else if (component.customId === "promote") {
if (
- currentRoleIndex == -1 ? allowed[data.track.length - 1] :
+ currentRoleIndex === -1 ? allowed[data.track.length - 1] :
allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
) {
- if (currentRoleIndex == -1) {
+ if (currentRoleIndex === -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])
}
}
- } else if (component.customId == "demote") {
+ } else if (component.customId === "demote") {
if(allowed[currentRoleIndex]) {
- if (currentRoleIndex == data.track.length - 1) {
+ if (currentRoleIndex === data.track.length - 1) {
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])
}
}
- } else if (component.customId == "select") {
+ } else if (component.customId === "select") {
track = component.values[0]
}
}
@@ -166,7 +163,7 @@
if (tracks.length === 0) throw "This server does not have any tracks"
let 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
tracks.forEach(element => {
@@ -174,7 +171,7 @@
if (element.track.manageableBy.some(role => member.roles.cache.has(role))) managed = true
});
// Check if the user has manage_roles permission
- if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
// Allow track
return true;
}