Fix a bunch of linter errors
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index 9a8e80a..dc224e8 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -7,30 +7,47 @@
export async function callback(interaction) {
const config = await client.database.guilds.read(interaction.guild.id);
- if (!config.roleMenu.enabled) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Self roles are currently disabled. Please contact a staff member or try again later.")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
- if (config.roleMenu.options.length === 0) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("There are no roles available. Please contact a staff member or try again later.")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+ if (!config.roleMenu.enabled)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription(
+ "Self roles are currently disabled. Please contact a staff member or try again later."
+ )
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ ephemeral: true
+ });
+ if (config.roleMenu.options.length === 0)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription(
+ "There are no roles available. Please contact a staff member or try again later."
+ )
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ ephemeral: true
+ });
+ await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
let m;
if (config.roleMenu.allowWebUI) {
let code = "";
let length = 5;
let itt = 0;
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ const chars =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let valid = false;
while (!valid) {
itt += 1;
code = "";
- for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
+ for (let i = 0; i < length; i++) {
+ code += chars.charAt(Math.floor(Math.random() * chars.length));
+ }
if (code in client.roleMenu) continue;
if (itt > 1000) {
itt = 0;
@@ -42,7 +59,7 @@
client.roleMenu[code] = {
guild: interaction.guild.id,
guildName: interaction.guild.name,
- guildIcon: interaction.guild.iconURL({format: "png"}),
+ guildIcon: interaction.guild.iconURL({ format: "png" }),
user: interaction.member.user.id,
username: interaction.member.user.username,
data: config.roleMenu.options,
@@ -50,31 +67,44 @@
};
let up = true;
try {
- const status = await fetch(client.config.baseUrl).then(res => res.status);
+ const status = await fetch(client.config.baseUrl).then(
+ (res) => res.status
+ );
if (status !== 200) up = false;
- } catch { up = false; }
+ } catch {
+ up = false;
+ }
m = await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Select how to choose your roles")
- .setStatus("Success")
- .setEmoji("GUILD.GREEN")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Online")
- .setStyle("LINK")
- .setDisabled(!up)
- .setURL(`${client.config.baseUrl}nucleus/rolemenu?code=${code}`),
- new MessageButton()
- .setLabel("Manual")
- .setStyle("PRIMARY")
- .setCustomId("manual")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription("Select how to choose your roles")
+ .setStatus("Success")
+ .setEmoji("GUILD.GREEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Online")
+ .setStyle("LINK")
+ .setDisabled(!up)
+ .setURL(
+ `${client.config.baseUrl}nucleus/rolemenu?code=${code}`
+ ),
+ new MessageButton()
+ .setLabel("Manual")
+ .setStyle("PRIMARY")
+ .setCustomId("manual")
+ ])
+ ]
});
}
let component;
- try { component = await m.awaitMessageComponent({time: 300000});
- } catch (e) { return; }
+ try {
+ component = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ return;
+ }
component.deferUpdate();
let rolesToAdd = [];
for (let i = 0; i < config.roleMenu.options.length; i++) {
@@ -84,36 +114,66 @@
new EmojiEmbed()
.setTitle("Roles")
.setEmoji("GUILD.GREEN")
- .setDescription(`**${object.name}**` + (object.description ? `\n${object.description}` : "") +
- `\n\nSelect ${object.min}` + (object.min !== object.max ? ` to ${object.max}` : "") + ` role${object.max === 1 ? "" : "s"} to add.`)
+ .setDescription(
+ `**${object.name}**` +
+ (object.description
+ ? `\n${object.description}`
+ : "") +
+ `\n\nSelect ${object.min}` +
+ (object.min !== object.max
+ ? ` to ${object.max}`
+ : "") +
+ ` role${object.max === 1 ? "" : "s"} to add.`
+ )
.setStatus("Success")
- .setFooter({text: `Step ${i + 1}/${config.roleMenu.options.length}`})
+ .setFooter({
+ text: `Step ${i + 1}/${config.roleMenu.options.length}`
+ })
],
components: [
+ new MessageActionRow().addComponents(
+ [
+ new MessageButton()
+ .setLabel("Cancel")
+ .setStyle("DANGER")
+ .setCustomId("cancel")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ].concat(
+ object.min === 0
+ ? [
+ new MessageButton()
+ .setLabel("Skip")
+ .setStyle("SECONDARY")
+ .setCustomId("skip")
+ .setEmoji(
+ getEmojiByName("CONTROL.RIGHT", "id")
+ )
+ ]
+ : []
+ )
+ )
+ ].concat([
new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Cancel")
- .setStyle("DANGER")
- .setCustomId("cancel")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ].concat(object.min === 0 ? [
- new MessageButton()
- .setLabel("Skip")
- .setStyle("SECONDARY")
- .setCustomId("skip")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- ] : []))
- ].concat([new MessageActionRow().addComponents([new MessageSelectMenu()
- .setPlaceholder(`${object.name}`)
- .setCustomId("rolemenu")
- .setMinValues(object.min)
- .setMaxValues(object.max)
- .setOptions(object.options.map(o => { return {label: o.name, description: o.description, value: o.role}; }))
- ])])
+ new MessageSelectMenu()
+ .setPlaceholder(`${object.name}`)
+ .setCustomId("rolemenu")
+ .setMinValues(object.min)
+ .setMaxValues(object.max)
+ .setOptions(
+ object.options.map((o) => {
+ return {
+ label: o.name,
+ description: o.description,
+ value: o.role
+ };
+ })
+ )
+ ])
+ ])
});
let component;
try {
- component = await m.awaitMessageComponent({time: 300000});
+ component = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
return;
}
@@ -121,34 +181,54 @@
if (component.customId === "rolemenu") {
rolesToAdd = rolesToAdd.concat(component.values);
} else if (component.customId === "cancel") {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Cancelled. No changes were made.")
- .setStatus("Danger")
- .setEmoji("GUILD.RED")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription("Cancelled. No changes were made.")
+ .setStatus("Danger")
+ .setEmoji("GUILD.RED")
+ ],
+ components: []
+ });
}
}
- let rolesToRemove = config.roleMenu.options.map(o => o.options.map(o => o.role)).flat();
- const memberRoles = interaction.member.roles.cache.map(r => r.id);
- rolesToRemove = rolesToRemove.filter(r => memberRoles.includes(r)).filter(r => !rolesToAdd.includes(r));
- rolesToAdd = rolesToAdd.filter(r => !memberRoles.includes(r));
+ let rolesToRemove = config.roleMenu.options
+ .map((o) => o.options.map((o) => o.role))
+ .flat();
+ const memberRoles = interaction.member.roles.cache.map((r) => r.id);
+ rolesToRemove = rolesToRemove
+ .filter((r) => memberRoles.includes(r))
+ .filter((r) => !rolesToAdd.includes(r));
+ rolesToAdd = rolesToAdd.filter((r) => !memberRoles.includes(r));
try {
await interaction.member.roles.remove(rolesToRemove);
await interaction.member.roles.add(rolesToAdd);
} catch (e) {
- return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Something went wrong and your roles were not added. Please contact a staff member or try again later.")
- .setStatus("Danger")
- .setEmoji("GUILD.RED")
- ], components: []});
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription(
+ "Something went wrong and your roles were not added. Please contact a staff member or try again later."
+ )
+ .setStatus("Danger")
+ .setEmoji("GUILD.RED")
+ ],
+ components: []
+ });
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Roles")
- .setDescription("Roles have been added. You may close this message.")
- .setStatus("Success")
- .setEmoji("GUILD.GREEN")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Roles")
+ .setDescription(
+ "Roles have been added. You may close this message."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.GREEN")
+ ],
+ components: []
+ });
return;
}