fixed loads of typing errors

pull/11/head
PineaFan 3 years ago
parent 633866ff68
commit b0d0c249cc
No known key found for this signature in database
GPG Key ID: D404018735F488C9

@ -87,8 +87,8 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
`Select a command to get started${(interaction.member?.permissions as PermissionsBitField).has("ManageGuild") ? `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server` : ``}` // FIXME `Select a command to get started${(interaction.member?.permissions as PermissionsBitField).has("ManageGuild") ? `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server` : ``}` // FIXME
) )
} else { } else {
let currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/')); const currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
let current = commands.find((command) => command.name === currentPath[0])!; const current = commands.find((command) => command.name === currentPath[0])!;
let optionString = `` let optionString = ``
let options: (ApplicationCommandOption & { let options: (ApplicationCommandOption & {
@ -97,16 +97,16 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
})[] = []; })[] = [];
//options //options
if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") { if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") {
let Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup const Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
let Op2 = Op.options!.find(option => option.name === currentPath[2])! const Op2 = Op.options!.find(option => option.name === currentPath[2])!
options = Op2.options || [] options = Op2.options ?? []
} else if(currentPath[1] !== "" && currentPath[1] !== "none") { } else if(currentPath[1] !== "" && currentPath[1] !== "none") {
let Op = current.options.find(option => option.name === currentPath[1])! let Op = current.options.find(option => option.name === currentPath[1])!
if(Op.type === ApplicationCommandOptionType.SubcommandGroup) { if(Op.type === ApplicationCommandOptionType.SubcommandGroup) {
options = [] options = []
} else { } else {
Op = Op as ApplicationCommandSubCommand Op = Op as ApplicationCommandSubCommand
options = Op.options || [] options = Op.options ?? []
} }
} else { } else {
options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || []; options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || [];
@ -117,7 +117,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0] const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0]
let allowedToRun = true; let allowedToRun = true;
if(APICommand?.check) { if(APICommand?.check) {
APICommand?.check(interaction as Interaction, true) allowedToRun = await APICommand.check(interaction as Interaction, true)
} }
embed.setDescription( embed.setDescription(
`${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${currentData.mention}\n\n` + `${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${currentData.mention}\n\n` +
@ -136,7 +136,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
...subcommandGroups.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name)) ...subcommandGroups.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name))
) )
if(subcommandGroupRow.components[0]!.options.find((option) => option.data.default && option.data.value !== "none")) { if(subcommandGroupRow.components[0]!.options.find((option) => option.data.default && option.data.value !== "none")) {
let subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) || []; const subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) ?? [];
subcommandRow.components[0]! subcommandRow.components[0]!
.addOptions( .addOptions(
new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[2] === "none"), new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[2] === "none"),
@ -152,7 +152,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
} }
} }
let cmps = [commandRow]; const cmps = [commandRow];
if(subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow); if(subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow);
if(subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow); if(subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow);
@ -163,20 +163,23 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
i = await m.awaitMessageComponent<ComponentType.StringSelect>({filter: (newInteraction) => interaction.user.id === newInteraction.user.id,time: 300000}) i = await m.awaitMessageComponent<ComponentType.StringSelect>({filter: (newInteraction) => interaction.user.id === newInteraction.user.id,time: 300000})
} catch (e) { } catch (e) {
closed = true; closed = true;
break; continue;
} }
await i.deferUpdate(); await i.deferUpdate();
let value = i.values[0]!; const value = i.values[0]!;
switch(i.customId) { switch(i.customId) {
case "commandRow": case "commandRow": {
currentPath = [value, "", ""]; currentPath = [value, "", ""];
break; break;
case "subcommandGroupRow": }
case "subcommandGroupRow": {
currentPath = [currentPath[0], value , ""]; currentPath = [currentPath[0], value , ""];
break; break;
case "subcommandRow": }
case "subcommandRow": {
currentPath[2] = value; currentPath[2] = value;
break; break;
}
} }
} while (!closed); } while (!closed);

@ -79,39 +79,37 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
} catch (e) { } catch (e) {
return; return;
} }
if (i) { i.deferUpdate();
i.deferUpdate(); const guild = i.guild!;
let guild = i.guild!; if (count - appliesTo.length <= 0) {
if (count - appliesTo.length <= 0) { interaction.editReply({
interaction.editReply({ embeds: [
embeds: [ new EmojiEmbed()
new EmojiEmbed() .setTitle("Premium")
.setTitle("Premium") .setDescription(
.setDescription( `You have already activated premium on the maximum amount of servers!` + firstDescription
`You have already activated premium on the maximum amount of servers!` + firstDescription )
) .setEmoji("NUCLEUS.PREMIUMACTIVATE")
.setEmoji("NUCLEUS.PREMIUMACTIVATE") .setStatus("Danger")
.setStatus("Danger") ],
], components: []
components: [] });
}); closed = true;
closed = true; } else {
} else { client.database.premium.addPremium(interaction.user.id, guild.id);
client.database.premium.addPremium(interaction.user.id, guild.id); interaction.editReply({
interaction.editReply({ embeds: [
embeds: [ new EmojiEmbed()
new EmojiEmbed() .setTitle("Premium")
.setTitle("Premium") .setDescription(
.setDescription( `You have activated premium on this server!` + firstDescription
`You have activated premium on this server!` + firstDescription )
) .setEmoji("NUCLEUS.LOGO")
.setEmoji("NUCLEUS.LOGO") .setStatus("Danger")
.setStatus("Danger") ],
], components: []
components: [] });
}); closed = true;
closed = true;
}
} }
} while (!closed); } while (!closed);

@ -48,28 +48,30 @@ const listToAndMore = (list: string[], max: number) => {
const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message, ids: string[], type: "member" | "role" | "channel", title: string): Promise<string[]> => { const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message, ids: string[], type: "member" | "role" | "channel", title: string): Promise<string[]> => {
const back = new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setCustomId("back").setLabel("Back").setStyle(ButtonStyle.Secondary).setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)); const back = new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setCustomId("back").setLabel("Back").setStyle(ButtonStyle.Secondary).setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji));
let closed; let closed;
do { do {
let render: string[] = [] let render: string[] = []
let mapped: string[] = []; let mapped: string[] = [];
let menu: UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder; let menu: UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder;
switch(type) { switch(type) {
case "member": case "member": {
menu = new UserSelectMenuBuilder().setCustomId("user").setPlaceholder("Select users").setMaxValues(25); menu = new UserSelectMenuBuilder().setCustomId("user").setPlaceholder("Select users").setMaxValues(25);
mapped = await Promise.all(ids.map(async (id) => { return (await client.users.fetch(id).then(user => user.tag)) || "Unknown User" })); mapped = await Promise.all(ids.map(async (id) => { return (await client.users.fetch(id).then(user => user.tag)) || "Unknown User" }));
render = ids.map(id => client.logger.renderUser(id)) render = ids.map(id => client.logger.renderUser(id))
break; break;
case "role": }
case "role": {
menu = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select roles").setMaxValues(25); menu = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select roles").setMaxValues(25);
mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name)) || "Unknown Role" })); mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name ?? "Unknown Role"))}));
render = ids.map(id => client.logger.renderRole(id, interaction.guild!)) render = ids.map(id => client.logger.renderRole(id, interaction.guild!))
break; break;
case "channel": }
case "channel": {
menu = new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select channels").setMaxValues(25); menu = new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select channels").setMaxValues(25);
mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name)) || "Unknown Channel" })); mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name ?? "Unknown Role")) }));
render = ids.map(id => client.logger.renderChannel(id)) render = ids.map(id => client.logger.renderChannel(id))
break; break;
}
} }
const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>() const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents( .addComponents(
@ -85,7 +87,7 @@ const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message
.setEmoji(getEmojiByName("GUILD.SETTINGS.GREEN")) .setEmoji(getEmojiByName("GUILD.SETTINGS.GREEN"))
.setDescription(`Select ${type}s:\n\nCurrent:\n` + (render.length > 0 ? render.join("\n") : "None")) .setDescription(`Select ${type}s:\n\nCurrent:\n` + (render.length > 0 ? render.join("\n") : "None"))
.setStatus("Success"); .setStatus("Success");
let components: ActionRowBuilder< const components: ActionRowBuilder<
StringSelectMenuBuilder | StringSelectMenuBuilder |
ButtonBuilder | ButtonBuilder |
ChannelSelectMenuBuilder | ChannelSelectMenuBuilder |
@ -102,7 +104,7 @@ const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message
i = await m.awaitMessageComponent({filter: i => i.user.id === interaction.user.id, time: 300000}); i = await m.awaitMessageComponent({filter: i => i.user.id === interaction.user.id, time: 300000});
} catch(e) { } catch(e) {
closed = true; closed = true;
break; continue;
} }
if(i.isButton()) { if(i.isButton()) {
@ -176,15 +178,18 @@ const imageMenu = async (interaction: StringSelectMenuInteraction, m: Message, c
} }
await i.deferUpdate(); await i.deferUpdate();
switch(i.customId) { switch(i.customId) {
case "back": case "back": {
closed = true; closed = true;
break; break;
case "nsfw": }
case "nsfw": {
current.NSFW = !current.NSFW; current.NSFW = !current.NSFW;
break; break;
case "size": }
case "size": {
current.size = !current.size; current.size = !current.size;
break; break;
}
} }
} while(!closed); } while(!closed);
return current; return current;
@ -267,16 +272,18 @@ const wordMenu = async (interaction: StringSelectMenuInteraction, m: Message, cu
if(i.isButton()) { if(i.isButton()) {
await i.deferUpdate(); await i.deferUpdate();
switch(i.customId) { switch(i.customId) {
case "back": case "back": {
closed = true; closed = true;
break; break;
case "enabled": }
case "enabled": {
current.enabled = !current.enabled; current.enabled = !current.enabled;
break; break;
}
} }
} else { } else {
switch(i.values[0]) { switch(i.values[0]) {
case "words": case "words": {
await interaction.editReply({embeds: [new EmojiEmbed() await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Word Filter") .setTitle("Word Filter")
.setDescription("Modal opened. If you can't see it, click back and try again.") .setDescription("Modal opened. If you can't see it, click back and try again.")
@ -298,7 +305,7 @@ const wordMenu = async (interaction: StringSelectMenuInteraction, m: Message, cu
.setCustomId("wordStrict") .setCustomId("wordStrict")
.setLabel("Strict Words") .setLabel("Strict Words")
.setPlaceholder("Matches anywhere in the message, including surrounded by other characters") .setPlaceholder("Matches anywhere in the message, including surrounded by other characters")
.setValue(current.words.strict.join(", ") ?? "") .setValue(current.words.strict.join(", "))
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setRequired(false) .setRequired(false)
), ),
@ -308,7 +315,7 @@ const wordMenu = async (interaction: StringSelectMenuInteraction, m: Message, cu
.setCustomId("wordLoose") .setCustomId("wordLoose")
.setLabel("Loose Words") .setLabel("Loose Words")
.setPlaceholder("Matches only if the word is by itself, surrounded by spaces or punctuation") .setPlaceholder("Matches only if the word is by itself, surrounded by spaces or punctuation")
.setValue(current.words.loose.join(", ") ?? "") .setValue(current.words.loose.join(", "))
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setRequired(false) .setRequired(false)
) )
@ -333,18 +340,22 @@ const wordMenu = async (interaction: StringSelectMenuInteraction, m: Message, cu
current.words.loose = out.fields.getTextInputValue("wordLoose") current.words.loose = out.fields.getTextInputValue("wordLoose")
.split(",").map(s => s.trim()).filter(s => s.length > 0); .split(",").map(s => s.trim()).filter(s => s.length > 0);
break; break;
case "allowedUsers": }
case "allowedUsers": {
await i.deferUpdate(); await i.deferUpdate();
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter"); current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter");
break; break;
case "allowedRoles": }
case "allowedRoles": {
await i.deferUpdate(); await i.deferUpdate();
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter"); current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter");
break; break;
case "allowedChannels": }
case "allowedChannels": {
await i.deferUpdate(); await i.deferUpdate();
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter"); current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter");
break; break;
}
} }
} }
} while(!closed); } while(!closed);
@ -420,25 +431,30 @@ const inviteMenu = async (interaction: StringSelectMenuInteraction, m: Message,
if(i.isButton()) { if(i.isButton()) {
await i.deferUpdate(); await i.deferUpdate();
switch(i.customId) { switch(i.customId) {
case "back": case "back": {
closed = true; closed = true;
break; break;
case "enabled": }
case "enabled": {
current.enabled = !current.enabled; current.enabled = !current.enabled;
break; break;
}
} }
} else { } else {
await i.deferUpdate(); await i.deferUpdate();
switch(i.values[0]) { switch(i.values[0]) {
case "users": case "users": {
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings"); current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings");
break; break;
case "roles": }
case "roles": {
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings"); current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings");
break; break;
case "channels": }
case "channels": {
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings"); current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings");
break; break;
}
} }
} }
@ -557,21 +573,24 @@ const mentionMenu = async (interaction: StringSelectMenuInteraction, m: Message,
if(i.isButton()) { if(i.isButton()) {
await i.deferUpdate(); await i.deferUpdate();
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
closed = true; closed = true;
break; break;
case "everyone": }
case "everyone": {
current.everyone = !current.everyone; current.everyone = !current.everyone;
break; break;
case "roles": }
case "roles": {
current.roles = !current.roles; current.roles = !current.roles;
break; break;
}
} }
} else { } else {
switch (i.customId) { switch (i.customId) {
case "toEdit": case "toEdit": {
switch (i.values[0]) { switch (i.values[0]) {
case "mass": case "mass": {
await interaction.editReply({embeds: [new EmojiEmbed() await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Word Filter") .setTitle("Word Filter")
.setDescription("Modal opened. If you can't see it, click back and try again.") .setDescription("Modal opened. If you can't see it, click back and try again.")
@ -613,26 +632,33 @@ const mentionMenu = async (interaction: StringSelectMenuInteraction, m: Message,
if(out.isButton()) break; if(out.isButton()) break;
current.mass = parseInt(out.fields.getTextInputValue("mass")); current.mass = parseInt(out.fields.getTextInputValue("mass"));
break; break;
case "roles": }
case "roles": {
await i.deferUpdate(); await i.deferUpdate();
current.allowed.rolesToMention = await toSelectMenu(interaction, m, current.allowed.rolesToMention, "role", "Mention Settings"); current.allowed.rolesToMention = await toSelectMenu(interaction, m, current.allowed.rolesToMention, "role", "Mention Settings");
break; break;
}
} }
break; break;
case "allowed": }
case "allowed": {
await i.deferUpdate(); await i.deferUpdate();
switch (i.values[0]) { switch (i.values[0]) {
case "users": case "users": {
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings"); current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings");
break; break;
case "roles": }
case "roles": {
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings"); current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings");
break; break;
case "channels": }
case "channels": {
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Mention Settings"); current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Mention Settings");
break; break;
}
} }
break; break;
}
} }
} }
@ -706,34 +732,38 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 300000}) as StringSelectMenuInteraction | ButtonInteraction; i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 300000}) as StringSelectMenuInteraction | ButtonInteraction;
} catch (e) { } catch (e) {
closed = true; closed = true;
return; continue;
} }
if(!i) return;
if(i.isButton()) { if(i.isButton()) {
await i.deferUpdate(); await i.deferUpdate();
await client.database.guilds.write(interaction.guild.id, {filters: config}); await client.database.guilds.write(interaction.guild.id, {filters: config});
} else { } else {
switch(i.values[0]) { switch(i.values[0]) {
case "invites": case "invites": {
await i.deferUpdate(); await i.deferUpdate();
config.invite = await inviteMenu(i, m, config.invite); config.invite = await inviteMenu(i, m, config.invite);
break; break;
case "mentions": }
case "mentions": {
await i.deferUpdate(); await i.deferUpdate();
config.pings = await mentionMenu(i, m, config.pings); config.pings = await mentionMenu(i, m, config.pings);
break; break;
case "words": }
case "words": {
await i.deferUpdate(); await i.deferUpdate();
config.wordFilter = await wordMenu(i, m, config.wordFilter); config.wordFilter = await wordMenu(i, m, config.wordFilter);
break; break;
case "malware": }
case "malware": {
await i.deferUpdate(); await i.deferUpdate();
config.malware = !config.malware; config.malware = !config.malware;
break; break;
case "images": }
let next = await imageMenu(i, m, config.images); case "images": {
if(next) config.images = next; const next = await imageMenu(i, m, config.images);
config.images = next;
break; break;
}
} }
} }

@ -41,7 +41,7 @@ const defaultRolePageConfig = {
} }
const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => { const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => {
let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>() const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents( .addComponents(
new StringSelectMenuBuilder() new StringSelectMenuBuilder()
.setCustomId("reorder") .setCustomId("reorder")
@ -55,7 +55,7 @@ const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message,
) )
) )
); );
let buttonRow = new ActionRowBuilder<ButtonBuilder>() const buttonRow = new ActionRowBuilder<ButtonBuilder>()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId("back") .setCustomId("back")
@ -85,7 +85,6 @@ const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message,
if(!out) return; if(!out) return;
out.deferUpdate(); out.deferUpdate();
if (out.isButton()) return; if (out.isButton()) return;
if(!out.values) return;
const values = out.values; const values = out.values;
const newOrder: ObjectSchema[] = currentObj.map((_, i) => { const newOrder: ObjectSchema[] = currentObj.map((_, i) => {
@ -156,7 +155,6 @@ const editNameDescription = async (i: ButtonInteraction, interaction: StringSele
} }
if(!out) return [name, description]; if(!out) return [name, description];
if (out.isButton()) return [name, description]; if (out.isButton()) return [name, description];
if(!out.fields) return [name, description];
name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name; name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
description = out.fields.fields.find((f) => f.customId === "description")?.value ?? description; description = out.fields.fields.find((f) => f.customId === "description")?.value ?? description;
return [name, description] return [name, description]
@ -223,19 +221,22 @@ const editRoleMenuPage = async (interaction: StringSelectMenuInteraction | Butto
} }
} else if (i.isButton()) { } else if (i.isButton()) {
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
await i.deferUpdate(); await i.deferUpdate();
back = true; back = true;
break; break;
case "edit": }
let [name, description] = await editNameDescription(i, interaction, m, data); case "edit": {
const [name, description] = await editNameDescription(i, interaction, m, data);
data.name = name ? name : data.name; data.name = name ? name : data.name;
data.description = description ? description : data.description; data.description = description ? description : data.description;
break; break;
case "addRole": }
case "addRole": {
await i.deferUpdate(); await i.deferUpdate();
data.options.push(await createRoleMenuOptionPage(interaction, m)); data.options.push(await createRoleMenuOptionPage(interaction, m));
break; break;
}
} }
} }
@ -247,9 +248,9 @@ const editRoleMenuPage = async (interaction: StringSelectMenuInteraction | Butto
const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data?: {name: string; description: string | null; role: string}) => { const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data?: {name: string; description: string | null; role: string}) => {
const { renderRole} = client.logger; const { renderRole} = client.logger;
if (!data) data = { if (!data) data = {
name: "Role Menu Option", name: "New role Menu Option",
description: null, description: null,
role: "No role set" role: ""
}; };
let back = false; let back = false;
const buttons = new ActionRowBuilder<ButtonBuilder>() const buttons = new ActionRowBuilder<ButtonBuilder>()
@ -268,11 +269,11 @@ const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction
do { do {
const roleSelect = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder(data.role ? "Set role to" : "Set the role"); const roleSelect = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder(data.role ? "Set role to" : "Set the role");
const embed = new EmojiEmbed() const embed = new EmojiEmbed()
.setTitle(`${data.name ?? "New Role Menu Option"}`) .setTitle(`${data.name}`)
.setStatus("Success") .setStatus("Success")
.setDescription( .setDescription(
`**Description:**\n> ${data.description ?? "No description set"}\n\n` + `**Description:**\n> ${data.description ?? "No description set"}\n\n` +
`**Role:** ${renderRole((await interaction.guild!.roles.fetch(data.role))!) ?? "No role set"}\n` `**Role:** ${data.role ? renderRole((await interaction.guild!.roles.fetch(data.role))!) : "No role set"}\n`
) )
interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect), buttons]}); interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect), buttons]});
@ -292,16 +293,18 @@ const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction
} }
} else if (i.isButton()) { } else if (i.isButton()) {
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
await i.deferUpdate(); await i.deferUpdate();
back = true; back = true;
break; break;
case "edit": }
case "edit": {
await i.deferUpdate(); await i.deferUpdate();
let [name, description] = await editNameDescription(i, interaction, m, data as {name: string; description: string}); const [name, description] = await editNameDescription(i, interaction, m, data as {name: string; description: string});
data.name = name ? name : data.name; data.name = name ? name : data.name;
data.description = description ? description : data.description; data.description = description ? description : data.description;
break; break;
}
} }
} }
} while (!back); } while (!back);
@ -409,54 +412,63 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction; i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) { } catch (e) {
closed = true; closed = true;
break; continue;
} }
await i.deferUpdate(); await i.deferUpdate();
if (i.isButton()) { if (i.isButton()) {
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
page--; page--;
break; break;
case "next": }
case "next": {
page++; page++;
break; break;
case "add": }
let newPage = await editRoleMenuPage(i, m) case "add": {
const newPage = await editRoleMenuPage(i, m)
if(!newPage) break; if(!newPage) break;
currentObject.push(); currentObject.push();
page = currentObject.length - 1; page = currentObject.length - 1;
break; break;
case "reorder": }
let reordered = await reorderRoleMenuPages(interaction, m, currentObject); case "reorder": {
const reordered = await reorderRoleMenuPages(interaction, m, currentObject);
if(!reordered) break; if(!reordered) break;
currentObject = reordered; currentObject = reordered;
break; break;
case "save": }
case "save": {
client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject}); client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});
modified = false; modified = false;
break; break;
}
} }
} else if (i.isStringSelectMenu()) { } else if (i.isStringSelectMenu()) {
switch (i.customId) { switch (i.customId) {
case "action": case "action": {
switch(i.values[0]) { switch(i.values[0]) {
case "edit": case "edit": {
let edited = await editRoleMenuPage(i, m, current!); const edited = await editRoleMenuPage(i, m, current!);
if(!edited) break; if(!edited) break;
currentObject[page] = edited; currentObject[page] = edited;
modified = true; modified = true;
break; break;
case "delete": }
case "delete": {
if(page === 0 && currentObject.keys.length - 1 > 0) page++; if(page === 0 && currentObject.keys.length - 1 > 0) page++;
else page--; else page--;
currentObject.splice(page, 1); currentObject.splice(page, 1);
break; break;
}
} }
break; break;
case "page": }
case "page": {
page = parseInt(i.values[0]!); page = parseInt(i.values[0]!);
break; break;
}
} }
} }

@ -136,11 +136,12 @@ const addStatsChannel = async (interaction: CommandInteraction, m: Message, curr
} }
if (i.isButton()) { if (i.isButton()) {
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
await i.deferUpdate(); await i.deferUpdate();
closed = true; closed = true;
break; break;
case "save": }
case "save": {
await i.deferUpdate(); await i.deferUpdate();
if (newChannel) { if (newChannel) {
currentObject[newChannel] = { currentObject[newChannel] = {
@ -150,7 +151,8 @@ const addStatsChannel = async (interaction: CommandInteraction, m: Message, curr
} }
closed = true; closed = true;
break; break;
case "editName": }
case "editName": {
await interaction.editReply({ await interaction.editReply({
embeds: [new EmojiEmbed() embeds: [new EmojiEmbed()
.setTitle("Stats Channel") .setTitle("Stats Channel")
@ -170,20 +172,21 @@ const addStatsChannel = async (interaction: CommandInteraction, m: Message, curr
}); });
showModal(i, {name: newChannelName, enabled: newChannelEnabled}) showModal(i, {name: newChannelName, enabled: newChannelEnabled})
const out = await modalInteractionCollector( const out: Discord.ModalSubmitInteraction | ButtonInteraction| null = await modalInteractionCollector(
m, m,
(m) => m.channel!.id === interaction.channel!.id && m.user!.id === interaction.user!.id, (m) => m.channel!.id === interaction.channel!.id && m.user!.id === interaction.user!.id,
(i) => i.channel!.id === interaction.channel!.id && i.user!.id === interaction.user!.id && i.message!.id === m.id (i) => i.channel!.id === interaction.channel!.id && i.user!.id === interaction.user!.id && i.message!.id === m.id
) as Discord.ModalSubmitInteraction | null; );
if (!out) continue; if (!out) continue;
if (!out.fields) continue;
if (out.isButton()) continue; if (out.isButton()) continue;
newChannelName = out.fields.getTextInputValue("text"); newChannelName = out.fields.getTextInputValue("text");
break; break;
case "toggleEnabled": }
case "toggleEnabled": {
await i.deferUpdate(); await i.deferUpdate();
newChannelEnabled = !newChannelEnabled; newChannelEnabled = !newChannelEnabled;
break; break;
}
} }
} else { } else {
await i.deferUpdate(); await i.deferUpdate();
@ -307,11 +310,12 @@ const callback = async (interaction: CommandInteraction) => {
if(i.isStringSelectMenu()) { if(i.isStringSelectMenu()) {
switch(i.customId) { switch(i.customId) {
case "page": case "page": {
await i.deferUpdate(); await i.deferUpdate();
page = Object.keys(currentObject).indexOf(i.values[0]!); page = Object.keys(currentObject).indexOf(i.values[0]!);
break; break;
case "action": }
case "action": {
modified = true; modified = true;
switch(i.values[0]!) { switch(i.values[0]!) {
case "edit": { case "edit": {
@ -345,7 +349,6 @@ const callback = async (interaction: CommandInteraction) => {
continue; continue;
} }
if (!out) continue if (!out) continue
if (!out.fields) continue
if (out.isButton()) continue; if (out.isButton()) continue;
currentObject[Object.keys(currentObject)[page]!]!.name = out.fields.getTextInputValue("text"); currentObject[Object.keys(currentObject)[page]!]!.name = out.fields.getTextInputValue("text");
break; break;
@ -358,32 +361,37 @@ const callback = async (interaction: CommandInteraction) => {
} }
case "delete": { case "delete": {
await i.deferUpdate(); await i.deferUpdate();
delete currentObject[Object.keys(currentObject)[page]!]; currentObject = Object.fromEntries(Object.entries(currentObject).filter(([k]) => k !== Object.keys(currentObject)[page]!));
page = Math.min(page, Object.keys(currentObject).length - 1); page = Math.min(page, Object.keys(currentObject).length - 1);
modified = true; modified = true;
break; break;
} }
} }
break; break;
}
} }
} else { } else {
await i.deferUpdate(); await i.deferUpdate();
switch(i.customId) { switch(i.customId) {
case "back": case "back": {
page--; page--;
break; break;
case "next": }
case "next": {
page++; page++;
break; break;
case "add": }
case "add": {
currentObject = await addStatsChannel(interaction, m, currentObject); currentObject = await addStatsChannel(interaction, m, currentObject);
page = Object.keys(currentObject).length - 1; page = Object.keys(currentObject).length - 1;
break; break;
case "save": }
case "save": {
client.database.guilds.write(interaction.guild.id, {stats: currentObject}); client.database.guilds.write(interaction.guild.id, {stats: currentObject});
singleNotify("statsChannelDeleted", interaction.guild.id, true); singleNotify("statsChannelDeleted", interaction.guild.id, true);
modified = false; modified = false;
break; break;
}
} }
} }

@ -723,7 +723,7 @@ async function manageTypes(interaction: CommandInteraction, data: GuildConfig["t
data.customTypes.push(toAdd); data.customTypes.push(toAdd);
} }
} else if ((i.component as ButtonComponent).customId === "switchToDefault") { } else if ((i.component as ButtonComponent).customId === "switchToDefault") {
await i.deferUpdate(); await i.deferUpdate();
await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": false }, []); await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": false }, []);
data.useCustom = false; data.useCustom = false;
} else if ((i.component as ButtonComponent).customId === "switchToCustom") { } else if ((i.component as ButtonComponent).customId === "switchToCustom") {

@ -37,7 +37,7 @@ const editName = async (i: ButtonInteraction, interaction: StringSelectMenuInter
.setCustomId("name") .setCustomId("name")
.setPlaceholder("Name here...") // TODO: Make better placeholder .setPlaceholder("Name here...") // TODO: Make better placeholder
.setStyle(TextInputStyle.Short) .setStyle(TextInputStyle.Short)
.setValue(name ?? "") .setValue(name)
.setRequired(true) .setRequired(true)
) )
) )
@ -74,14 +74,13 @@ const editName = async (i: ButtonInteraction, interaction: StringSelectMenuInter
} }
if(!out) return name; if(!out) return name;
if (out.isButton()) return name; if (out.isButton()) return name;
if(!out.fields) return name;
name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name; name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
return name return name
} }
const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles: Collection<string, Role>, currentObj: string[]) => { const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles: Collection<string, Role>, currentObj: string[]) => {
let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>() const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents( .addComponents(
new StringSelectMenuBuilder() new StringSelectMenuBuilder()
.setCustomId("reorder") .setCustomId("reorder")
@ -95,7 +94,7 @@ const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles:
) )
) )
); );
let buttonRow = new ActionRowBuilder<ButtonBuilder>() const buttonRow = new ActionRowBuilder<ButtonBuilder>()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId("back") .setCustomId("back")
@ -125,7 +124,6 @@ const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles:
if(!out) return; if(!out) return;
out.deferUpdate(); out.deferUpdate();
if (out.isButton()) return; if (out.isButton()) return;
if(!out.values) return;
const values = out.values; const values = out.values;
const newOrder: string[] = currentObj.map((_, i) => { const newOrder: string[] = currentObj.map((_, i) => {
@ -204,7 +202,7 @@ const editTrack = async (interaction: ButtonInteraction | StringSelectMenuIntera
.setEmoji(getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji) .setEmoji(getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji)
); );
let allowed: boolean[] = []; const allowed: boolean[] = [];
for (const role of current.track) { for (const role of current.track) {
const disabled: boolean = const disabled: boolean =
roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position; roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position;
@ -241,39 +239,46 @@ const editTrack = async (interaction: ButtonInteraction | StringSelectMenuIntera
if (out.isButton()) { if (out.isButton()) {
out.deferUpdate(); out.deferUpdate();
switch(out.customId) { switch(out.customId) {
case "back": case "back": {
closed = true; closed = true;
break; break;
case "edit": }
case "edit": {
current.name = (await editName(out, interaction, message, current.name))!; current.name = (await editName(out, interaction, message, current.name))!;
break; break;
case "reorder": }
case "reorder": {
current.track = (await reorderTracks(out, message, roles, current.track))!; current.track = (await reorderTracks(out, message, roles, current.track))!;
break; break;
case "retainPrevious": }
case "retainPrevious": {
current.retainPrevious = !current.retainPrevious; current.retainPrevious = !current.retainPrevious;
break; break;
case "nullable": }
case "nullable": {
current.nullable = !current.nullable; current.nullable = !current.nullable;
break; break;
}
} }
} else if (out.isStringSelectMenu()) { } else if (out.isStringSelectMenu()) {
out.deferUpdate(); out.deferUpdate();
switch(out.customId) { switch(out.customId) {
case "removeRole": case "removeRole": {
const index = current.track.findIndex(v => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]); const index = current.track.findIndex(v => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]);
current.track.splice(index, 1); current.track.splice(index, 1);
break; break;
}
} }
} else { } else {
switch(out.customId) { switch(out.customId) {
case "addRole": case "addRole": {
const role = out.values![0]!; const role = out.values![0]!;
if(!current.track.includes(role)) { if(!current.track.includes(role)) {
current.track.push(role); current.track.push(role);
} }
out.reply({content: "That role is already on this track", ephemeral: true}) out.reply({content: "That role is already on this track", ephemeral: true})
break; break;
}
} }
} }
@ -381,54 +386,61 @@ const callback = async (interaction: CommandInteraction) => {
i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction; i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) { } catch (e) {
closed = true; closed = true;
break; continue;
} }
await i.deferUpdate(); await i.deferUpdate();
if (i.isButton()) { if (i.isButton()) {
switch (i.customId) { switch (i.customId) {
case "back": case "back": {
page--; page--;
break; break;
case "next": }
case "next": {
page++; page++;
break; break;
case "add": }
let newPage = await editTrack(i, m, roles) case "add": {
const newPage = await editTrack(i, m, roles)
if(!newPage) break; if(!newPage) break;
tracks.push(); tracks.push();
page = tracks.length - 1; page = tracks.length - 1;
break; break;
case "save": }
case "save": {
client.database.guilds.write(interaction.guild!.id, {tracks: tracks}); client.database.guilds.write(interaction.guild!.id, {tracks: tracks});
modified = false; modified = false;
break; break;
}
} }
} else if (i.isStringSelectMenu()) { } else if (i.isStringSelectMenu()) {
switch (i.customId) { switch (i.customId) {
case "action": case "action": {
switch(i.values[0]) { switch(i.values[0]) {
case "edit": case "edit": {
let edited = await editTrack(i, m, roles, current!); const edited = await editTrack(i, m, roles, current!);
if(!edited) break; if(!edited) break;
tracks[page] = edited; tracks[page] = edited;
modified = true; modified = true;
break; break;
case "delete": }
case "delete": {
if(page === 0 && tracks.keys.length - 1 > 0) page++; if(page === 0 && tracks.keys.length - 1 > 0) page++;
else page--; else page--;
tracks.splice(page, 1); tracks.splice(page, 1);
break; break;
}
} }
break; break;
case "page": }
case "page": {
page = parseInt(i.values[0]!); page = parseInt(i.values[0]!);
break; break;
}
} }
} }
} while (!closed) } while (!closed)
} }
const check = (interaction: CommandInteraction, _partial: boolean = false) => { const check = (interaction: CommandInteraction, _partial: boolean = false) => {

@ -17,10 +17,10 @@ interface MalwareSchema {
export async function testNSFW(link: string): Promise<NSFWSchema> { export async function testNSFW(link: string): Promise<NSFWSchema> {
const [p, hash] = await saveAttachment(link); const [p, hash] = await saveAttachment(link);
let alreadyHaveCheck = await client.database.scanCache.read(hash) const alreadyHaveCheck = await client.database.scanCache.read(hash)
if(alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data }; if(alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
const data = new URLSearchParams(); const data = new URLSearchParams();
let r = createReadStream(p) const r = createReadStream(p)
data.append("file", r.read(fs.statSync(p).size)); data.append("file", r.read(fs.statSync(p).size));
const result = await fetch("https://unscan.p.rapidapi.com/", { const result = await fetch("https://unscan.p.rapidapi.com/", {
method: "POST", method: "POST",
@ -43,10 +43,10 @@ export async function testNSFW(link: string): Promise<NSFWSchema> {
export async function testMalware(link: string): Promise<MalwareSchema> { export async function testMalware(link: string): Promise<MalwareSchema> {
const [p, hash] = await saveAttachment(link); const [p, hash] = await saveAttachment(link);
let alreadyHaveCheck = await client.database.scanCache.read(hash) const alreadyHaveCheck = await client.database.scanCache.read(hash)
if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data }; if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data };
const data = new URLSearchParams(); const data = new URLSearchParams();
let f = createReadStream(p); const f = createReadStream(p);
data.append("file", f.read(fs.statSync(p).size)); data.append("file", f.read(fs.statSync(p).size));
const result = await fetch("https://unscan.p.rapidapi.com/malware", { const result = await fetch("https://unscan.p.rapidapi.com/malware", {
method: "POST", method: "POST",
@ -68,7 +68,7 @@ export async function testMalware(link: string): Promise<MalwareSchema> {
} }
export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> { export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> {
let alreadyHaveCheck = await client.database.scanCache.read(link) const alreadyHaveCheck = await client.database.scanCache.read(link)
if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data, tags: [] }; if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data, tags: [] };
const scanned: { safe?: boolean; tags?: string[] } = await fetch("https://unscan.p.rapidapi.com/link", { const scanned: { safe?: boolean; tags?: string[] } = await fetch("https://unscan.p.rapidapi.com/link", {
method: "POST", method: "POST",

@ -33,7 +33,7 @@ class NucleusClient extends Client {
check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean, check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]> autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
} | undefined,{name: string, description: string}]> = {}; } | undefined,{name: string, description: string}]> = {};
fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection(); fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
constructor(database: typeof NucleusClient.prototype.database) { constructor(database: typeof NucleusClient.prototype.database) {
super({ intents: [ super({ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds,

@ -32,7 +32,7 @@ export async function group(
if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) } if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) }
for (const subcommand of fetched.subcommands) { for (const subcommand of fetched.subcommands) {
let processedCommand = subcommand.command(new SlashCommandSubcommandBuilder()); const processedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
client.commands["commands/" + path + "/" + processedCommand.name] = [subcommand, { name: processedCommand.name, description: processedCommand.description }] client.commands["commands/" + path + "/" + processedCommand.name] = [subcommand, { name: processedCommand.name, description: processedCommand.description }]
subcommandGroup.addSubcommand(processedCommand); subcommandGroup.addSubcommand(processedCommand);
}; };
@ -80,7 +80,7 @@ export async function command(
command.addSubcommand(fetchedCommand); command.addSubcommand(fetchedCommand);
} }
for (const group of fetched.subcommandGroups) { for (const group of fetched.subcommandGroups) {
let processedCommand = group.command(new SlashCommandSubcommandGroupBuilder()); const processedCommand = group.command(new SlashCommandSubcommandGroupBuilder());
client.commands[commandString! + "/" + processedCommand.name] = [undefined, { name: processedCommand.name, description: processedCommand.description }] client.commands[commandString! + "/" + processedCommand.name] = [undefined, { name: processedCommand.name, description: processedCommand.description }]
command.addSubcommandGroup(processedCommand); command.addSubcommandGroup(processedCommand);
}; };

@ -10,7 +10,7 @@ const wait = promisify(setTimeout);
export const Logger = { export const Logger = {
renderUser(user: Discord.User | string) { renderUser(user: Discord.User | string) {
if (typeof user === "string") user = client.users.cache.get(user) as Discord.User; if (typeof user === "string") user = client.users.cache.get(user)!;
return `${user.username} [<@${user.id}>]`; return `${user.username} [<@${user.id}>]`;
}, },
renderTime(t: number) { renderTime(t: number) {
@ -34,7 +34,7 @@ export const Logger = {
return `${channel.name} [<#${channel.id}>]`; return `${channel.name} [<#${channel.id}>]`;
}, },
renderRole(role: Discord.Role | string, guild?: Discord.Guild | string) { renderRole(role: Discord.Role | string, guild?: Discord.Guild | string) {
if (typeof role === "string") role = (typeof guild === "string" ? client.guilds.cache.get(guild) : guild)!.roles.cache.get(role) as Discord.Role; if (typeof role === "string") role = (typeof guild === "string" ? client.guilds.cache.get(guild) : guild)!.roles.cache.get(role)!;
return `${role.name} [<@&${role.id}>]`; return `${role.name} [<@&${role.id}>]`;
}, },
renderEmoji(emoji: Discord.GuildEmoji) { renderEmoji(emoji: Discord.GuildEmoji) {

Loading…
Cancel
Save