Reformat using prettier
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 0eb8580..7e2902e 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -29,11 +29,15 @@
const guild = interaction.guild!;
const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember;
await userAbout(guild, member, interaction);
-}
+};
-async function userAbout(guild: Discord.Guild, member: Discord.GuildMember, interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction) {
- await member.user.fetch()
- await member.fetch()
+async function userAbout(
+ guild: Discord.Guild,
+ member: Discord.GuildMember,
+ interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction
+) {
+ await member.user.fetch();
+ await member.fetch();
await interaction.reply({
embeds: LoadingEmbed,
fetchReply: true,
@@ -59,10 +63,18 @@
) {
flags.push("CLICKSDEVELOPER");
}
- if (member.user.flags) { member.user.flags.toArray().map((flag) => { flags.push(flag.toString()); }); }
- if (member.user.bot) { flags.push("BOT"); }
+ if (member.user.flags) {
+ member.user.flags.toArray().map((flag) => {
+ flags.push(flag.toString());
+ });
+ }
+ if (member.user.bot) {
+ flags.push("BOT");
+ }
// Check if they are boosting the server
- if (member.premiumSince) { flags.push("BOOSTER"); }
+ if (member.premiumSince) {
+ flags.push("BOOSTER");
+ }
const nameReplacements: Record<string, string> = {
NUCLEUSDEVELOPER: "**Nucleus Developer**",
CLICKSDEVELOPER: "Clicks Developer",
@@ -79,7 +91,8 @@
Staff: "Discord Staff",
VerifiedDeveloper: "Verified Bot Developer",
ActiveDeveloper: "Active Developer",
- Quarantined: "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
+ Quarantined:
+ "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
Spammer: "Likely Spammer"
// CertifiedModerator
// VerifiedBot
@@ -139,24 +152,27 @@
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
.setDescription(
- flags.map((flag) => {
- if (nameReplacements[flag]) {
- const emoji = getEmojiByName(`BADGES.${flag}`)
- if (emoji) return (emoji + " " + nameReplacements[flag] + "\n");
- else return nameReplacements[flag] + "\n";
- }
- }).join("") + "\n" +
- generateKeyValueList({
- member: renderUser(member.user),
- nickname: member.nickname ?? "*None set*",
- id: `\`${member.id}\``,
- "joined the server": renderDelta(member.joinedTimestamp!),
- "joined discord": renderDelta(member.user.createdTimestamp),
- "boost status": member.premiumSince
- ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
- : "*Not boosting*",
- "join position": `${joinPos + 1}`
- })
+ flags
+ .map((flag) => {
+ if (nameReplacements[flag]) {
+ const emoji = getEmojiByName(`BADGES.${flag}`);
+ if (emoji) return emoji + " " + nameReplacements[flag] + "\n";
+ else return nameReplacements[flag] + "\n";
+ }
+ })
+ .join("") +
+ "\n" +
+ generateKeyValueList({
+ member: renderUser(member.user),
+ nickname: member.nickname ?? "*None set*",
+ id: `\`${member.id}\``,
+ "joined the server": renderDelta(member.joinedTimestamp!),
+ "joined discord": renderDelta(member.user.createdTimestamp),
+ "boost status": member.premiumSince
+ ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
+ : "*Not boosting*",
+ "join position": `${joinPos + 1}`
+ })
)
.setThumbnail(member.user.displayAvatarURL())
)
@@ -174,7 +190,10 @@
member: renderUser(member.user),
id: `\`${member.id}\``,
roles: `${member.roles.cache.size - 1}`
- }) + "\n" + (s.length > 0 ? s : "*None*") + "\n"
+ }) +
+ "\n" +
+ (s.length > 0 ? s : "*None*") +
+ "\n"
)
)
.setTitle("Roles")
@@ -199,7 +218,9 @@
.setDescription("Key permissions the user has")
.setPageId(2)
];
- if (member.user.bannerURL() ) { embeds[0]!.embed.setImage(member.user.bannerURL()!); }
+ if (member.user.bannerURL()) {
+ embeds[0]!.embed.setImage(member.user.bannerURL()!);
+ }
let page = 0;
let timedOut = false;
for (const embed of embeds) {
@@ -255,7 +276,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch {
timedOut = true;
@@ -281,8 +308,8 @@
embeds: [em],
components: []
});
-};
+}
export { command };
export { callback };
-export { userAbout };
\ No newline at end of file
+export { userAbout };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index da33f51..6804695 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -35,6 +35,5 @@
});
};
-
export { command };
export { callback };
diff --git a/src/commands/user/role.ts b/src/commands/user/role.ts
index 41820ac..74b6c41 100644
--- a/src/commands/user/role.ts
+++ b/src/commands/user/role.ts
@@ -1,17 +1,29 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, GuildMember, Role, RoleSelectMenuBuilder, RoleSelectMenuInteraction, UserSelectMenuBuilder, UserSelectMenuInteraction } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ CommandInteraction,
+ GuildMember,
+ Role,
+ RoleSelectMenuBuilder,
+ RoleSelectMenuInteraction,
+ UserSelectMenuBuilder,
+ UserSelectMenuInteraction
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import client from "../../utils/client.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { LoadingEmbed } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import listToAndMore from "../../utils/listToAndMore.js"
+import listToAndMore from "../../utils/listToAndMore.js";
const { renderUser } = client.logger;
const canEdit = (role: Role, member: GuildMember, me: GuildMember): [string, boolean] => {
- if(role.position >= me.roles.highest.position ||
- role.position >= member.roles.highest.position
- ) return [`~~<@&${role.id}>~~`, false];
+ if (role.position >= me.roles.highest.position || role.position >= member.roles.highest.position)
+ return [`~~<@&${role.id}>~~`, false];
return [`<@&${role.id}>`, true];
};
@@ -19,103 +31,116 @@
builder
.setName("role")
.setDescription("Gives or removes a role from someone")
- .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"))
+ .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"));
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
let member = interaction.options.getMember("user") as GuildMember | null;
- if(!member) {
+ if (!member) {
const memberEmbed = new EmojiEmbed()
.setTitle("Role")
.setDescription(`Please choose a member to edit the roles of.`)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success");
const memberChooser = new ActionRowBuilder<UserSelectMenuBuilder>().addComponents(
- new UserSelectMenuBuilder()
- .setCustomId("memberChooser")
- .setPlaceholder("Select a member")
+ new UserSelectMenuBuilder().setCustomId("memberChooser").setPlaceholder("Select a member")
);
- await interaction.editReply({embeds: [memberEmbed], components: [memberChooser]});
+ await interaction.editReply({ embeds: [memberEmbed], components: [memberChooser] });
- const filter = (i: UserSelectMenuInteraction) => i.customId === "memberChooser" && i.user.id === interaction.user.id;
+ const filter = (i: UserSelectMenuInteraction) =>
+ i.customId === "memberChooser" && i.user.id === interaction.user.id;
let i: UserSelectMenuInteraction | null;
try {
- i = await m.awaitMessageComponent<5>({ filter, time: 300000});
+ i = await m.awaitMessageComponent<5>({ filter, time: 300000 });
} catch (e) {
return;
}
memberEmbed.setDescription(`Editing roles for ${renderUser(i.values[0]!)}`);
await i.deferUpdate();
- await interaction.editReply({ embeds: LoadingEmbed, components: [] })
+ await interaction.editReply({ embeds: LoadingEmbed, components: [] });
member = await interaction.guild?.members.fetch(i.values[0]!)!;
-
}
let closed = false;
let rolesToChange: string[] = [];
- const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("roleAdd")
- .setPlaceholder("Select a role to add")
- .setMaxValues(25)
- );
+ const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder().setCustomId("roleAdd").setPlaceholder("Select a role to add").setMaxValues(25)
+ );
do {
-
- const removing = rolesToChange.filter((r) => member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
- const adding = rolesToChange.filter((r) => !member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
- const embed = new EmojiEmbed()
- .setTitle("Role")
- .setDescription(
- `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
- `Adding:\n` +
- `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
- `Removing:\n` +
- `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
- )
- .setEmoji("GUILD.ROLES.CREATE")
- .setStatus("Success");
-
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("roleSave")
- .setLabel("Apply")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success),
- new ButtonBuilder()
- .setCustomId("roleDiscard")
- .setLabel("Reset")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Danger)
+ const removing = rolesToChange
+ .filter((r) => member!.roles.cache.has(r))
+ .map(
+ (r) =>
+ canEdit(
+ interaction.guild?.roles.cache.get(r)!,
+ interaction.member as GuildMember,
+ interaction.guild?.members.me!
+ )[0]
);
+ const adding = rolesToChange
+ .filter((r) => !member!.roles.cache.has(r))
+ .map(
+ (r) =>
+ canEdit(
+ interaction.guild?.roles.cache.get(r)!,
+ interaction.member as GuildMember,
+ interaction.guild?.members.me!
+ )[0]
+ );
+ const embed = new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription(
+ `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
+ `Adding:\n` +
+ `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
+ `Removing:\n` +
+ `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
+ )
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setStatus("Success");
+
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("roleSave")
+ .setLabel("Apply")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success),
+ new ButtonBuilder()
+ .setCustomId("roleDiscard")
+ .setLabel("Reset")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Danger)
+ );
await interaction.editReply({ embeds: [embed], components: [roleAdd, buttons] });
let i: RoleSelectMenuInteraction | ButtonInteraction | null;
try {
- i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 }) as RoleSelectMenuInteraction | ButtonInteraction;
+ i = (await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 })) as
+ | RoleSelectMenuInteraction
+ | ButtonInteraction;
} catch (e) {
closed = true;
continue;
}
i.deferUpdate();
- if(i.isButton()) {
- switch(i.customId) {
+ if (i.isButton()) {
+ switch (i.customId) {
case "roleSave": {
const roles = rolesToChange.map((r) => interaction.guild?.roles.cache.get(r)!);
await interaction.editReply({ embeds: LoadingEmbed, components: [] });
const rolesToAdd: Role[] = [];
const rolesToRemove: Role[] = [];
- for(const role of roles) {
- if(!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1]) continue;
- if(member.roles.cache.has(role.id)) {
+ for (const role of roles) {
+ if (!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1])
+ continue;
+ if (member.roles.cache.has(role.id)) {
rolesToRemove.push(role);
} else {
rolesToAdd.push(role);
@@ -135,9 +160,7 @@
} else {
rolesToChange = i.values;
}
-
} while (!closed);
-
};
const check = (interaction: CommandInteraction, partial: boolean = false) => {
@@ -145,7 +168,7 @@
// Check if the user has manage_roles permission
if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
if (partial) return true;
- if (!interaction.guild) return
+ if (!interaction.guild) return;
const me = interaction.guild.members.me!;
// Check if Nucleus has permission to role
if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index c7f441f..19b9da2 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,5 +1,17 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, GuildMember, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, APIMessageComponentEmoji, StringSelectMenuBuilder, MessageComponentInteraction, StringSelectMenuInteraction, StringSelectMenuOptionBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ APIMessageComponentEmoji,
+ StringSelectMenuBuilder,
+ MessageComponentInteraction,
+ StringSelectMenuInteraction,
+ StringSelectMenuOptionBuilder
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -14,7 +26,7 @@
.addUserOption((option) => option.setName("user").setDescription("The user to manage").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const { renderUser, renderRole} = client.logger;
+ const { renderUser, renderRole } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
if (!guild) return;
@@ -63,13 +75,15 @@
for (const role of data.track) {
const disabled: boolean =
roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position && !managed;
- allowed.push(!disabled)
+ allowed.push(!disabled);
}
- generated += "\n" + createVerticalTrack(
- data.track.map((role) => renderRole(roles.get(role)!)),
- data.track.map((role) => memberRoles.cache.has(role)),
- allowed.map((allow) => !allow)
- );
+ generated +=
+ "\n" +
+ createVerticalTrack(
+ data.track.map((role) => renderRole(roles.get(role)!)),
+ data.track.map((role) => memberRoles.cache.has(role)),
+ allowed.map((allow) => !allow)
+ );
const selected = [];
for (const position of data.track) {
if (memberRoles.cache.has(position)) selected.push(position);
@@ -117,7 +131,9 @@
],
components: [new ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>().addComponents(dropdown)]
.concat(
- conflict && conflictDropdown.length ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)] : []
+ conflict && conflictDropdown.length
+ ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)]
+ : []
)
.concat([
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -150,7 +166,13 @@
try {
component = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -158,7 +180,9 @@
}
component.deferUpdate();
if (component.customId === "conflict") {
- const rolesToRemove = selected.filter((role) => role !== (component as StringSelectMenuInteraction).values[0]);
+ const rolesToRemove = selected.filter(
+ (role) => role !== (component as StringSelectMenuInteraction).values[0]
+ );
await member.roles.remove(rolesToRemove);
} else if (component.customId === "promote") {
if (
@@ -196,7 +220,7 @@
if (member.id === interaction.guild!.ownerId) return true;
// Check if the user can manage any of the tracks
let managed = false;
- const memberRoles = member.roles.cache.map((r) => r.id)
+ const memberRoles = member.roles.cache.map((r) => r.id);
for (const element of tracks) {
if (!element.manageableBy.length) continue;
if (!element.manageableBy.some((role: string) => memberRoles.includes(role))) continue;