Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 23d5c66..7b6b309 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -11,43 +11,43 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("commands")
- .setDescription("Links and text shown to a user after a moderator action is performed")
- .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"))
+ .setName("commands")
+ .setDescription("Links and text shown to a user after a moderator action is performed")
+ .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"));
const callback = async (interaction: CommandInteraction): Promise<any> => {
await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
let m;
let clicked = "";
if (interaction.options.getRole("role")) {
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Moderation Commands")
.setDescription(keyValueList({
- role: `<@&${interaction.options.getRole("role").id}>`,
+ role: `<@&${interaction.options.getRole("role").id}>`
}))
.setColor("Danger")
- .send(true)
+ .send(true);
if (confirmation.cancelled) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Moderation Commands")
.setDescription("No changes were made")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
- ]})
+ ]});
if (confirmation.success) {
await client.database.guilds.write(interaction.guild.id, {["moderation.mute.role"]: interaction.options.getRole("role").id});
}
}
while (true) {
- let config = await client.database.guilds.read(interaction.guild.id);
- let moderation = config.getKey("moderation");
+ const config = await client.database.guilds.read(interaction.guild.id);
+ const moderation = config.getKey("moderation");
m = await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Moderation Commands")
.setEmoji("PUNISH.BAN.GREEN")
.setStatus("Success")
.setDescription(
"These links are shown below the message sent in a user's DM when they are punished.\n\n" +
- `**Mute Role:** ` + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
+ "**Mute Role:** " + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
)
], components: [new MessageActionRow().addComponents([
new MessageButton().setLabel("Warn").setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id")).setCustomId("warn").setStyle("SECONDARY"),
@@ -70,19 +70,19 @@
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return }
+ } catch (e) { return; }
let chosen = moderation[i.customId] ?? {text: null, url: null};
if (i.component.customId === "clearMuteRole") {
- i.deferUpdate()
+ i.deferUpdate();
if (clicked === "clearMuteRole") {
await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
- } else { clicked = "clearMuteRole" }
- continue
- } else { clicked = "" }
+ } else { clicked = "clearMuteRole"; }
+ continue;
+ } else { clicked = ""; }
if (i.component.customId === "timeout") {
- await i.deferUpdate()
+ await i.deferUpdate();
await client.database.guilds.write(interaction.guild.id, {"moderation.mute.timeout": !moderation.mute.timeout } );
- continue
+ continue;
} else if (i.customId) {
await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Options for ${i.customId}`).addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
@@ -101,7 +101,7 @@
.setStyle("SHORT")
.setValue(chosen.link ?? "")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Moderation Links")
@@ -117,27 +117,27 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => true)
- } catch (e) { continue }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => true);
+ } catch (e) { continue; }
if (out.fields) {
- let buttonText = out.fields.getTextInputValue("name");
- let buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
- let current = chosen;
+ const buttonText = out.fields.getTextInputValue("name");
+ const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
+ const current = chosen;
if (current.text !== buttonText || current.link !== buttonLink) {
chosen = { text: buttonText, link: buttonLink };
await client.database.guilds.write(interaction.guild.id, { ["moderation." + i.customId]: { text: buttonText, link: buttonLink }});
}
- } else { continue }
+ } else { continue; }
}
}
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/filters.ts b/src/commands/settings/filters.ts
index dfcff99..d35d210 100644
--- a/src/commands/settings/filters.ts
+++ b/src/commands/settings/filters.ts
@@ -1,28 +1,28 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from '../../utils/client.js';
-import confirmationMessage from '../../utils/confirmationMessage.js';
-import generateKeyValueList from '../../utils/generateKeyValueList.js';
-import { ChannelType } from 'discord-api-types';
-import getEmojiByName from '../../utils/getEmojiByName.js';
+import client from "../../utils/client.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import generateKeyValueList from "../../utils/generateKeyValueList.js";
+import { ChannelType } from "discord-api-types";
+import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("filter")
- .setDescription("Setting for message filters")
+ .setName("filter")
+ .setDescription("Setting for message filters");
const callback = async (interaction: CommandInteraction): Promise<any> => {
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 2dae74e..edd1c61 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,5 +1,5 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
+import { ChannelType } from "discord-api-types";
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
@@ -10,76 +10,74 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("attachments")
- .setDescription("Where attachments should be logged to (Premium only)")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]).setRequired(false))
+ .setName("attachments")
+ .setDescription("Where attachments should be logged to (Premium only)")
+ .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
+ ChannelType.GuildNews, ChannelType.GuildText
+ ]).setRequired(false));
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getChannel("channel")) {
- let channel
+ let channel;
try {
- channel = interaction.options.getChannel("channel")
+ channel = interaction.options.getChannel("channel");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Attachment Log Channel")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
- ]})
+ ]});
}
- channel = channel as Discord.TextChannel
+ channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Attachment Log Channel")
- .setDescription(`You must choose a channel in this server`)
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Attachment Log Channel")
.setDescription(
- `This will be the channel all attachments will be sent to.\n\n` +
+ "This will be the channel all attachments will be sent to.\n\n" +
`Are you sure you want to set the attachment log channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id})
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
- try {
- let data = {
- meta:{
- type: 'attachmentChannelUpdate',
- displayName: 'Attachment Log Channel Updated',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: interaction.guild.id
- }
+ await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id});
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const data = {
+ meta:{
+ type: "attachmentChannelUpdate",
+ displayName: "Attachment Log Channel Updated",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(channel.id, renderChannel(channel))
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Attachment Log Channel")
- .setDescription(`Something went wrong and the attachment log channel could not be set`)
+ .setDescription("Something went wrong and the attachment log channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
], components: []});
@@ -87,14 +85,14 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Attachment Log Channel")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
], components: []});
}
}
let clicks = 0;
- let data = await client.database.guilds.read(interaction.guild.id);
+ const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -115,17 +113,17 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
- i.deferUpdate()
+ } catch(e) { break; }
+ i.deferUpdate();
if (i.component.customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"]);
channel = undefined;
}
} else {
- break
+ break;
}
}
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -141,13 +139,13 @@
.setStyle("SECONDARY")
.setDisabled(true)
])]});
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 4030108..da0d156 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,5 +1,5 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
+import { ChannelType } from "discord-api-types";
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
@@ -10,74 +10,72 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("channel")
- .setDescription("Sets or shows the log channel")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]))
+ .setName("channel")
+ .setDescription("Sets or shows the log channel")
+ .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
+ ChannelType.GuildNews, ChannelType.GuildText
+ ]));
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getChannel("channel")) {
- let channel
+ let channel;
try {
- channel = interaction.options.getChannel("channel")
+ channel = interaction.options.getChannel("channel");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Log Channel")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
- ]})
+ ]});
}
- channel = channel as Discord.TextChannel
+ channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
- .setDescription(`You must choose a channel in this server`)
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Log Channel")
.setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id})
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
- try {
- let data = {
- meta:{
- type: 'logChannelUpdate',
- displayName: 'Log Channel Changed',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: channel.guild.id
- }
+ await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id});
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const data = {
+ meta:{
+ type: "logChannelUpdate",
+ displayName: "Log Channel Changed",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(channel.id, renderChannel(channel))
+ },
+ hidden: {
+ guild: channel.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
- console.log(e)
+ console.log(e);
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
- .setDescription(`Something went wrong and the log channel could not be set`)
+ .setDescription("Something went wrong and the log channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
], components: []});
@@ -85,14 +83,14 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
], components: []});
}
}
let clicks = 0;
- let data = await client.database.guilds.read(interaction.guild.id);
+ const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.logs.channel;
while (true) {
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -110,17 +108,17 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
- i.deferUpdate()
+ } catch(e) { break; }
+ i.deferUpdate();
if (i.component.customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"]);
channel = undefined;
}
} else {
- break
+ break;
}
}
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -136,13 +134,13 @@
.setStyle("SECONDARY")
.setDisabled(true)
])]});
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index ef303cb..88386c4 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,9 +1,9 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
-import client from '../../../utils/client.js';
+import client from "../../../utils/client.js";
import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
@@ -27,20 +27,20 @@
"guildMemberVerify": "Member runs verify",
"autoModeratorDeleted": "Messages auto deleted by Nucleus",
"nucleusSettingsUpdated": "Nucleus' settings updated by a moderator",
- "ticketUpdate": "Tickets created or deleted",
-}
+ "ticketUpdate": "Tickets created or deleted"
+};
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("events")
- .setDescription("Sets what events should be logged")
+ .setName("events")
+ .setDescription("Sets what events should be logged");
const callback = async (interaction: CommandInteraction): Promise<any> => {
await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
let m;
while (true) {
- let config = await client.database.guilds.read(interaction.guild.id)
- let converted = toHexArray(config.logging.logs.toLog)
+ const config = await client.database.guilds.read(interaction.guild.id);
+ const converted = toHexArray(config.logging.logs.toLog);
m = await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Logging Events")
.setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
@@ -68,25 +68,25 @@
.setStyle("DANGER")
.setCustomId("none")
])
- ]})
+ ]});
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- break
+ break;
}
- i.deferUpdate()
+ i.deferUpdate();
if (i.customId === "logs") {
- let selected = i.values;
- let newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]))
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs})
+ const selected = i.values;
+ const newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]));
+ await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
} else if (i.customId === "all") {
- let newLogs = toHexInteger(Object.keys(logs).map(e => e))
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs})
+ const newLogs = toHexInteger(Object.keys(logs).map(e => e));
+ await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
} else if (i.customId === "none") {
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0})
+ await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0});
} else {
- break
+ break;
}
}
m = await interaction.editReply({embeds: [new EmojiEmbed()
@@ -95,14 +95,14 @@
.setFooter({text: "Message timed out"})
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
- ]})
-}
+ ]});
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 5867338..2f0c819 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,85 +1,85 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
+import { ChannelType } from "discord-api-types";
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("staff")
- .setDescription("Settings for the staff notifications channel")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]).setRequired(false))
+ .setName("staff")
+ .setDescription("Settings for the staff notifications channel")
+ .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
+ ChannelType.GuildNews, ChannelType.GuildText
+ ]).setRequired(false));
-const callback = async (interaction: CommandInteraction): Promise<any> => {
- let m;
- m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (interaction: CommandInteraction): Promise<unknown | void> => {
+ if (!interaction.guild) return;
+ const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message<boolean>;
if (interaction.options.getChannel("channel")) {
- let channel
+ let channel;
try {
- channel = interaction.options.getChannel("channel")
+ channel = interaction.options.getChannel("channel");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Staff Notifications Channel")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
- ]})
+ ]});
}
- channel = channel as Discord.TextChannel
+ channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
- .setDescription(`You must choose a channel in this server`)
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Staff Notifications Channel")
.setDescription(
- `This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n` +
+ "This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n" +
`Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id})
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
- try {
- let data = {
- meta:{
- type: 'staffChannelUpdate',
- displayName: 'Staff Notifications Channel Updated',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: interaction.guild.id
- }
+ await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id});
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const data = {
+ meta:{
+ type: "staffChannelUpdate",
+ displayName: "Staff Notifications Channel Updated",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(channel.id, renderChannel(channel))
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
- .setDescription(`Something went wrong and the staff notifications channel could not be set`)
+ .setDescription("Something went wrong and the staff notifications channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
], components: []});
@@ -87,14 +87,14 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
], components: []});
}
}
let clicks = 0;
- let data = await client.database.guilds.read(interaction.guild.id);
+ const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -112,17 +112,17 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
- i.deferUpdate()
- if (i.component.customId === "clear") {
+ } catch(e) { break; }
+ i.deferUpdate();
+ if ((i.component as MessageButton).customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"])
+ await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"]);
channel = undefined;
}
} else {
- break
+ break;
}
}
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -138,13 +138,13 @@
.setStyle("SECONDARY")
.setDisabled(true)
])]});
-}
+};
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 891b6f1..9a4ceb0 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -1,25 +1,23 @@
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
+import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("rolemenu")
- .setDescription("rolemenu")// TODO
- .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")) // TODO
+ .setName("rolemenu")
+ .setDescription("rolemenu")// TODO
+ .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")); // FIXME FOR FUCK SAKE
-const callback = async (interaction: CommandInteraction): Promise<any> => {
-}
+const callback = async (interaction: CommandInteraction): Promise<void> => {
+ console.log("we changed the charger again because fuck you");
+ await interaction.reply("You're mum");
+};
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command"
+const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 10fba6b..4d61496 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,23 +1,23 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageSelectMenu } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js";
-import convertCurlyBracketString from '../../utils/convertCurlyBracketString.js';
+import convertCurlyBracketString from "../../utils/convertCurlyBracketString.js";
import {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
-import singleNotify from '../../utils/singleNotify.js';
+import singleNotify from "../../utils/singleNotify.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("stats")
- .setDescription("Controls channels which update when someone joins or leaves the server")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to modify"))
- .addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true))
+ .setName("stats")
+ .setDescription("Controls channels which update when someone joins or leaves the server")
+ .addChannelOption(option => option.setName("channel").setDescription("The channel to modify"))
+ .addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true));
const callback = async (interaction: CommandInteraction): Promise<any> => {
- singleNotify("statsChannelDeleted", interaction.guild.id, true)
+ singleNotify("statsChannelDeleted", interaction.guild.id, true);
let m;
m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
let config = await client.database.guilds.read(interaction.guild.id);
@@ -29,72 +29,70 @@
.setTitle("Stats Channel")
.setDescription("You can only have 25 stats channels in a server")
.setStatus("Danger")
- ]})
+ ]});
}
try {
- channel = interaction.options.getChannel("channel")
+ channel = interaction.options.getChannel("channel");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Stats Channel")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
- ]})
+ ]});
}
- channel = channel as Discord.TextChannel
+ channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
- .setDescription(`You must choose a channel in this server`)
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]});
}
- let newName = await convertCurlyBracketString(interaction.options.getString("name"), null, null, interaction.guild.name, interaction.guild.members)
+ let newName = await convertCurlyBracketString(interaction.options.getString("name"), null, null, interaction.guild.name, interaction.guild.members);
if (interaction.options.getChannel("channel").type === "GUILD_TEXT") {
- newName = newName.toLowerCase().replace(/[\s]/g, "-")
+ newName = newName.toLowerCase().replace(/[\s]/g, "-");
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Stats Channel")
.setDescription(`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(/^ +| $/g, "")}*`)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- let name = interaction.options.getString("name")
- let channel = interaction.options.getChannel("channel")
+ const name = interaction.options.getString("name");
+ const channel = interaction.options.getChannel("channel");
await client.database.guilds.write(interaction.guild.id, {[`stats.${channel.id}`]: {name: name, enabled: true}});
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
- try {
- let data = {
- meta:{
- type: 'statsChannelUpdate',
- displayName: 'Stats Channel Updated',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- name: entry(interaction.options.getString("name"), `\`${interaction.options.getString("name")}\``)
- },
- hidden: {
- guild: interaction.guild.id
- }
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const data = {
+ meta:{
+ type: "statsChannelUpdate",
+ displayName: "Stats Channel Updated",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(channel.id, renderChannel(channel)),
+ name: entry(interaction.options.getString("name"), `\`${interaction.options.getString("name")}\``)
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
- console.log(e)
+ console.log(e);
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
- .setDescription(`Something went wrong and the stats channel could not be set`)
+ .setDescription("Something went wrong and the stats channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
], components: []});
@@ -102,7 +100,7 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
], components: []});
@@ -111,11 +109,11 @@
}
while (true) {
config = await client.database.guilds.read(interaction.guild.id);
- let stats = config.getKey("stats")
- let selectMenu = new MessageSelectMenu()
+ const stats = config.getKey("stats");
+ const selectMenu = new MessageSelectMenu()
.setCustomId("remove")
.setMinValues(1)
- .setMaxValues(Math.max(1, Object.keys(stats).length))
+ .setMaxValues(Math.max(1, Object.keys(stats).length));
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription("The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list.")
@@ -126,30 +124,30 @@
selectMenu.setPlaceholder("Select a stats channel to remove, stopping it updating").addOptions(Object.keys(stats).map(key => ({
label: interaction.guild.channels.cache.get(key).name,
value: key,
- description: `${stats[key].name}`,
+ description: `${stats[key].name}`
})))
] : [selectMenu.setPlaceholder("The server has no stats channels").setDisabled(true).setOptions([
{label: "*Placeholder*", value: "placeholder", description: "No stats channels"}
])])
- ]})
+ ]});
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break }
- i.deferUpdate()
+ } catch (e) { break; }
+ i.deferUpdate();
if (i.customId === "remove") {
- let toRemove = i.values;
+ const toRemove = i.values;
await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
}
}
await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_CHANNELS")) throw "You must have the *Manage Channels* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_CHANNELS")) throw "You must have the *Manage Channels* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 8ebcf30..3d1901b 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,14 +1,14 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { ChannelType } from 'discord-api-types';
+import { ChannelType } from "discord-api-types";
import client from "../../utils/client.js";
import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
-import { capitalize } from '../../utils/generateKeyValueList.js';
+import { capitalize } from "../../utils/generateKeyValueList.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
const command = (builder: SlashCommandSubcommandBuilder) => builder
@@ -18,24 +18,24 @@
.addChoices([["Yes", "yes"], ["No", "no"]]))
.addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
.addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default: 5").setRequired(false).setMinValue(1))
- .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false))
+ .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false));
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
- m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
- let options = {
+ m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ const options = {
enabled: interaction.options.getString("enabled") as string | boolean,
category: interaction.options.getChannel("category"),
maxtickets: interaction.options.getNumber("maxticketsperuser"),
supportping: interaction.options.getRole("supportrole")
- }
- console.log(m)
+ };
+ console.log(m);
if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
options.enabled = options.enabled === "yes" ? true : false;
if (options.category) {
- let channel
+ let channel;
try {
- channel = interaction.guild.channels.cache.get(options.category.id)
+ channel = interaction.guild.channels.cache.get(options.category.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -44,13 +44,13 @@
.setDescription("The channel you provided is not a valid category")
.setStatus("Danger")
]
- })
+ });
}
- channel = channel as Discord.CategoryChannel
+ channel = channel as Discord.CategoryChannel;
if (channel.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Category")
- .setDescription(`You must choose a category in this server`)
+ .setDescription("You must choose a category in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -60,16 +60,16 @@
if (options.maxtickets < 1) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Max Tickets")
- .setDescription(`You must choose a number greater than 0`)
+ .setDescription("You must choose a number greater than 0")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
});
}
- let role
+ let role;
if (options.supportping) {
try {
- role = interaction.guild.roles.cache.get(options.supportping.id)
+ role = interaction.guild.roles.cache.get(options.supportping.id);
} catch {
return await interaction.editReply({
embeds: [new EmojiEmbed()
@@ -78,20 +78,20 @@
.setDescription("The role you provided is not a valid role")
.setStatus("Danger")
]
- })
+ });
}
- role = role as Discord.Role
+ role = role as Discord.Role;
if (role.guild.id !== interaction.guild.id) return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Support Ping")
- .setDescription(`You must choose a role in this server`)
+ .setDescription("You must choose a role in this server")
.setStatus("Danger")
.setEmoji("GUILD.ROLE.DELETE")
]
});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.TICKET.ARCHIVED")
.setTitle("Tickets")
.setDescription(
@@ -99,26 +99,26 @@
(options.maxtickets ? `**Max Tickets:** ${options.maxtickets}\n` : "") +
(options.supportping ? `**Support Ping:** ${options.supportping.name}\n` : "") +
(options.enabled !== null ? `**Enabled:** ${options.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- }\n` : "") +
- `\nAre you sure you want to apply these settings?`
+ }\n` : "") +
+ "\nAre you sure you want to apply these settings?"
)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
- let toUpdate = {}
- if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled
- if (options.category) toUpdate["tickets.category"] = options.category.id
- if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets
- if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id
+ const toUpdate = {};
+ if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled;
+ if (options.category) toUpdate["tickets.category"] = options.category.id;
+ if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets;
+ if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id;
try {
- await client.database.guilds.write(interaction.guild.id, toUpdate)
+ await client.database.guilds.write(interaction.guild.id, toUpdate);
} catch (e) {
return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets")
- .setDescription(`Something went wrong and the staff notifications channel could not be set`)
+ .setDescription("Something went wrong and the staff notifications channel could not be set")
.setStatus("Danger")
.setEmoji("GUILD.TICKET.DELETE")
], components: []
@@ -128,7 +128,7 @@
return interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
], components: []
@@ -136,7 +136,7 @@
}
}
let data = await client.database.guilds.read(interaction.guild.id);
- data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i)
+ data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i);
let lastClicked = "";
let embed;
data = {
@@ -147,7 +147,7 @@
useCustom: data.tickets.useCustom,
types: data.tickets.types,
customTypes: data.tickets.customTypes
- }
+ };
while (true) {
embed = new EmojiEmbed()
.setTitle("Tickets")
@@ -161,7 +161,7 @@
`${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
)
.setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
+ .setEmoji("GUILD.TICKET.OPEN");
m = await interaction.editReply({
embeds: [embed], components: [new MessageActionRow().addComponents([
new MessageButton()
@@ -186,7 +186,7 @@
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearSupportPing")
- .setDisabled(data.supportRole === null),
+ .setDisabled(data.supportRole === null)
]), new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Manage types")
@@ -197,40 +197,40 @@
.setLabel("Add create ticket button")
.setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("PRIMARY")
- .setCustomId("send"),
+ .setCustomId("send")
])]
});
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break }
- i.deferUpdate()
+ } catch (e) { break; }
+ i.deferUpdate();
if (i.component.customId === "clearCategory") {
if (lastClicked === "cat") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"]);
data.category = undefined;
} else lastClicked = "cat";
} else if (i.component.customId === "clearMaxTickets") {
if (lastClicked === "max") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"]);
data.maxTickets = 5;
} else lastClicked = "max";
} else if (i.component.customId === "clearSupportPing") {
if (lastClicked === "sup") {
lastClicked = "";
- await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"])
+ await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"]);
data.supportRole = undefined;
} else lastClicked = "sup";
} else if (i.component.customId === "send") {
const ticketMessages = [
{label: "Create ticket", description: "Click the button below to create a ticket"},
{label: "Issues, questions or feedback?", description: "Click below to open a ticket and get help from our staff team"},
- {label: "Contact Us", description: "Click the button below to speak to us privately"},
- ]
+ {label: "Contact Us", description: "Click the button below to speak to us privately"}
+ ];
while (true) {
- let enabled = data.enabled && data.category !== null;
+ const enabled = data.enabled && data.category !== null;
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Ticket Button")
.setDescription("Select a message template to send in this channel")
@@ -240,8 +240,8 @@
], components: [
new MessageActionRow().addComponents([
new MessageSelectMenu().setOptions(ticketMessages.map((t: {label: string, description: string, value?: string}, index) => {
- t.value = index.toString(); return t as {value: string, label: string, description: string}
- })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template"),
+ t.value = index.toString(); return t as {value: string, label: string, description: string};
+ })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
]),
new MessageActionRow().addComponents([
new MessageButton()
@@ -263,9 +263,9 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
+ } catch(e) { break; }
if (i.component.customId === "template") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(ticketMessages[parseInt(i.values[0])].label)
.setDescription(ticketMessages[parseInt(i.values[0])].description)
@@ -277,18 +277,18 @@
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
+ break;
} else if (i.component.customId === "blank") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
.setLabel("Create Ticket")
.setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
+ break;
} else if (i.component.customId === "custom") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Enter embed details`).addComponents(
+ await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("title")
.setLabel("Title")
@@ -303,7 +303,7 @@
.setRequired(true)
.setStyle("PARAGRAPH")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Ticket Button")
@@ -319,11 +319,11 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
- } catch (e) { break }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
+ } catch (e) { break; }
if (out.fields) {
- let title = out.fields.getTextInputValue("title");
- let description = out.fields.getTextInputValue("description");
+ const title = out.fields.getTextInputValue("title");
+ const description = out.fields.getTextInputValue("description");
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(title)
.setDescription(description)
@@ -335,26 +335,26 @@
.setStyle("SUCCESS")
.setCustomId("createticket")
])]});
- break
- } else { continue }
+ break;
+ } else { continue; }
}
}
} else if (i.component.customId === "enabled") {
- await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled });
data.enabled = !data.enabled;
} else if (i.component.customId === "manageTypes") {
data = await manageTypes(interaction, data, m);
} else {
- break
+ break;
}
}
await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
-}
+};
async function manageTypes(interaction, data, m) {
while (true) {
if (data.useCustom) {
- let customTypes = data.customTypes;
+ const customTypes = data.customTypes;
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -393,29 +393,29 @@
new MessageButton()
.setLabel("Switch to default types")
.setStyle("SECONDARY")
- .setCustomId("switchToDefault"),
+ .setCustomId("switchToDefault")
])
])
});
} else {
- let inUse = toHexArray(data.types, ticketTypes)
- let options = [];
+ const inUse = toHexArray(data.types, ticketTypes);
+ const options = [];
ticketTypes.forEach(type => {
options.push(new SelectMenuOption({
label: capitalize(type),
value: type,
emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")),
default: inUse.includes(type)
- }))
- })
- let selectPane = new MessageActionRow().addComponents([
+ }));
+ });
+ const selectPane = new MessageActionRow().addComponents([
new Discord.MessageSelectMenu()
.addOptions(options)
.setCustomId("types")
.setMaxValues(ticketTypes.length)
.setMinValues(1)
.setPlaceholder("Select types to use")
- ])
+ ]);
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -437,7 +437,7 @@
new MessageButton()
.setLabel("Switch to custom types")
.setStyle("SECONDARY")
- .setCustomId("switchToCustom"),
+ .setCustomId("switchToCustom")
])
]
});
@@ -445,20 +445,20 @@
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break }
+ } catch (e) { break; }
if (i.component.customId === "types") {
- i.deferUpdate()
- let types = toHexInteger(i.values, ticketTypes);
- await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
+ i.deferUpdate();
+ const types = toHexInteger(i.values, ticketTypes);
+ await client.database.guilds.write(interaction.guild.id, { "tickets.types": types });
data.types = types;
} else if (i.component.customId === "removeTypes") {
- i.deferUpdate()
- let types = i.values
+ i.deferUpdate();
+ const types = i.values;
let customTypes = data.customTypes;
if (customTypes) {
customTypes = customTypes.filter((t) => !types.includes(t));
customTypes = customTypes.length > 0 ? customTypes : null;
- await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes });
data.customTypes = customTypes;
}
} else if (i.component.customId === "addType") {
@@ -472,7 +472,7 @@
.setRequired(true)
.setStyle("SHORT")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
@@ -488,42 +488,42 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType")
- } catch (e) { continue }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType");
+ } catch (e) { continue; }
if (out.fields) {
let toAdd = out.fields.getTextInputValue("type");
- if (!toAdd) { continue }
- toAdd = toAdd.substring(0, 80)
+ if (!toAdd) { continue; }
+ toAdd = toAdd.substring(0, 80);
try {
- await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd)
- } catch { continue }
+ await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd);
+ } catch { continue; }
data.customTypes = data.customTypes || [];
if (!data.customTypes.includes(toAdd)) {
data.customTypes.push(toAdd);
}
- } else { continue }
+ } else { continue; }
} else if (i.component.customId === "switchToDefault") {
- i.deferUpdate()
- await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
+ i.deferUpdate();
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, []);
data.useCustom = false;
} else if (i.component.customId === "switchToCustom") {
- i.deferUpdate()
- await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
+ i.deferUpdate();
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, []);
data.useCustom = true;
} else {
- i.deferUpdate()
- break
+ i.deferUpdate();
+ break;
}
}
- return data
+ return data;
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index a77f2f4..c100d05 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, Emoji, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -6,76 +6,74 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js";
-import { modalInteractionCollector } from '../../utils/dualCollector.js';
+import { modalInteractionCollector } from "../../utils/dualCollector.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("verify")
- .setDescription("Manage the role given after typing /verify")
- .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false))
+ .setName("verify")
+ .setDescription("Manage the role given after typing /verify")
+ .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false));
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
if (interaction.options.getRole("role")) {
- let role
+ let role;
try {
- role = interaction.options.getRole("role")
+ role = interaction.options.getRole("role");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Verify Role")
.setDescription("The role you provided is not a valid role")
.setStatus("Danger")
- ]})
+ ]});
}
- role = role as Discord.Role
+ role = role as Discord.Role;
if (role.guild.id !== interaction.guild.id) {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
- .setDescription(`You must choose a role in this server`)
+ .setDescription("You must choose a role in this server")
.setStatus("Danger")
.setEmoji("GUILD.ROLES.DELETE")
]});
}
- let confirmation = await new confirmationMessage(interaction)
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.ROLES.EDIT")
.setTitle("Verify Role")
.setDescription(`Are you sure you want to set the verify role to <@&${role.id}>?`)
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
await client.database.guilds.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
- const { log, NucleusColors, entry, renderUser, renderRole } = client.logger
- try {
- let data = {
- meta:{
- type: 'verifyRoleChanged',
- displayName: 'Verify Role Changed',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.green,
- emoji: "CONTROL.BLOCKTICK",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- role: entry(role.id, renderRole(role)),
- },
- hidden: {
- guild: interaction.guild.id
- }
+ const { log, NucleusColors, entry, renderUser, renderRole } = client.logger;
+ const data = {
+ meta:{
+ type: "verifyRoleChanged",
+ displayName: "Verify Role Changed",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.green,
+ emoji: "CONTROL.BLOCKTICK",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ role: entry(role.id, renderRole(role))
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
- console.log(e)
+ console.log(e);
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
- .setDescription(`Something went wrong while setting the verify role`)
+ .setDescription("Something went wrong while setting the verify role")
.setStatus("Danger")
.setEmoji("GUILD.ROLES.DELETE")
], components: []});
@@ -83,19 +81,19 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
], components: []});
}
}
let clicks = 0;
- let data = await client.database.guilds.read(interaction.guild.id);
+ const data = await client.database.guilds.read(interaction.guild.id);
let role = data.verify.role;
while (true) {
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
- .setDescription(role ? `Your verify role is currently set to <@&${role}>` : `You have not set a verify role`)
+ .setDescription(role ? `Your verify role is currently set to <@&${role}>` : "You have not set a verify role")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
], components: [new MessageActionRow().addComponents([
@@ -114,21 +112,21 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
- i.deferUpdate()
+ } catch(e) { break; }
+ i.deferUpdate();
if (i.component.customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"])
+ await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
role = undefined;
}
} else if (i.component.customId === "send") {
const verifyMessages = [
{label: "Verify", description: "Click the button below to get verified"},
{label: "Get verified", description: "To get access to the rest of the server, click the button below"},
- {label: "Ready to verify?", description: "Click the button below to verify yourself"},
- ]
+ {label: "Ready to verify?", description: "Click the button below to verify yourself"}
+ ];
while (true) {
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Button")
@@ -139,8 +137,8 @@
], components: [
new MessageActionRow().addComponents([
new MessageSelectMenu().setOptions(verifyMessages.map((t: {label: string, description: string, value?: string}, index) => {
- t.value = index.toString(); return t as {value: string, label: string, description: string}
- })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template"),
+ t.value = index.toString(); return t as {value: string, label: string, description: string};
+ })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
]),
new MessageActionRow().addComponents([
new MessageButton()
@@ -162,9 +160,9 @@
let i;
try {
i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break }
+ } catch(e) { break; }
if (i.component.customId === "template") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(verifyMessages[parseInt(i.values[0])].label)
.setDescription(verifyMessages[parseInt(i.values[0])].description)
@@ -176,18 +174,18 @@
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])]});
- break
+ break;
} else if (i.component.customId === "blank") {
- i.deferUpdate()
+ i.deferUpdate();
await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
.setLabel("Verify")
.setEmoji(getEmojiByName("CONTROL.TICK", "id"))
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])]});
- break
+ break;
} else if (i.component.customId === "custom") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Enter embed details`).addComponents(
+ await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
.setCustomId("title")
.setLabel("Title")
@@ -202,7 +200,7 @@
.setRequired(true)
.setStyle("PARAGRAPH")
)
- ))
+ ));
await interaction.editReply({
embeds: [new EmojiEmbed()
.setTitle("Verify Button")
@@ -218,11 +216,11 @@
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
- } catch (e) { break }
+ out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
+ } catch (e) { break; }
if (out.fields) {
- let title = out.fields.getTextInputValue("title");
- let description = out.fields.getTextInputValue("description");
+ const title = out.fields.getTextInputValue("title");
+ const description = out.fields.getTextInputValue("description");
await interaction.channel.send({embeds: [new EmojiEmbed()
.setTitle(title)
.setDescription(description)
@@ -234,23 +232,23 @@
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])]});
- break
- } else { continue }
+ break;
+ } else { continue; }
}
}
} else {
- i.deferUpdate()
+ i.deferUpdate();
break;
}
}
await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 1a107ed..34ac292 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -1,109 +1,107 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from '../../utils/client.js';
-import confirmationMessage from '../../utils/confirmationMessage.js';
-import generateKeyValueList from '../../utils/generateKeyValueList.js';
-import { ChannelType } from 'discord-api-types';
-import getEmojiByName from '../../utils/getEmojiByName.js';
+import client from "../../utils/client.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import generateKeyValueList from "../../utils/generateKeyValueList.js";
+import { ChannelType } from "discord-api-types";
+import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
- .setName("welcome")
- .setDescription("Messages and roles sent or given when someone joins the server")
- .addStringOption(option => option.setName("message").setDescription("The message to send when someone joins the server").setAutocomplete(true))
- .addRoleOption(option => option.setName("role").setDescription("The role given when someone joins the server"))
- .addRoleOption(option => option.setName("ping").setDescription("The role pinged when someone joins the server"))
- .addChannelOption(option => option.setName("channel").setDescription("The channel the welcome message should be sent to").addChannelTypes([
- ChannelType.GuildText, ChannelType.GuildNews
- ]))
+ .setName("welcome")
+ .setDescription("Messages and roles sent or given when someone joins the server")
+ .addStringOption(option => option.setName("message").setDescription("The message to send when someone joins the server").setAutocomplete(true))
+ .addRoleOption(option => option.setName("role").setDescription("The role given when someone joins the server"))
+ .addRoleOption(option => option.setName("ping").setDescription("The role pinged when someone joins the server"))
+ .addChannelOption(option => option.setName("channel").setDescription("The channel the welcome message should be sent to").addChannelTypes([
+ ChannelType.GuildText, ChannelType.GuildNews
+ ]));
const callback = async (interaction: CommandInteraction): Promise<any> => {
- const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger
+ const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
let m;
if (interaction.options.getRole("role") || interaction.options.getChannel("channel") || interaction.options.getString("message")) {
let role;
let ping;
- let message = interaction.options.getString("message");
+ const message = interaction.options.getString("message");
try {
- role = interaction.options.getRole("role")
- ping = interaction.options.getRole("ping")
+ role = interaction.options.getRole("role");
+ ping = interaction.options.getRole("ping");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Welcome Events")
.setDescription("The role you provided is not a valid role")
.setStatus("Danger")
- ]})
+ ]});
}
let channel;
try {
- channel = interaction.options.getChannel("channel")
+ channel = interaction.options.getChannel("channel");
} catch {
return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Welcome Events")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
- ]})
+ ]});
}
- role = role as Discord.Role
- ping = ping as Discord.Role
- channel = channel as Discord.TextChannel
- let options = {}
- if (role) options["role"] = renderRole(role)
- if (ping) options["ping"] = renderRole(ping)
- if (channel) options["channel"] = renderChannel(channel)
- if (message) options["message"] = "\n> " + message
- let confirmation = await new confirmationMessage(interaction)
+ role = role as Discord.Role;
+ ping = ping as Discord.Role;
+ channel = channel as Discord.TextChannel;
+ const options = {};
+ if (role) options["role"] = renderRole(role);
+ if (ping) options["ping"] = renderRole(ping);
+ if (channel) options["channel"] = renderChannel(channel);
+ if (message) options["message"] = "\n> " + message;
+ const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.ROLES.EDIT")
.setTitle("Welcome Events")
.setDescription(generateKeyValueList(options))
.setColor("Warning")
.setInverted(true)
- .send(true)
- if (confirmation.cancelled) return
+ .send(true);
+ if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- let toChange = {}
- if (role) toChange["welcome.role"] = role.id
- if (ping) toChange["welcome.ping"] = ping.id
- if (channel) toChange["welcome.channel"] = channel.id
- if (message) toChange["welcome.message"] = message
+ const toChange = {};
+ if (role) toChange["welcome.role"] = role.id;
+ if (ping) toChange["welcome.ping"] = ping.id;
+ if (channel) toChange["welcome.channel"] = channel.id;
+ if (message) toChange["welcome.message"] = message;
await client.database.guilds.write(interaction.guild.id, toChange);
- let list = {
+ const list = {
memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
changedBy: entry(interaction.user.id, renderUser(interaction.user))
- }
- if (role) list["role"] = entry(role.id, renderRole(role))
- if (ping) list["ping"] = entry(ping.id, renderRole(ping))
- if (channel) list["channel"] = entry(channel.id, renderChannel(channel.id))
- if (message) list["message"] = entry(message, `\`${message}\``)
- try {
- let data = {
- meta:{
- type: 'welcomeSettingsUpdated',
- displayName: 'Welcome Settings Changed',
- calculateType: 'nucleusSettingsUpdated',
- color: NucleusColors.green,
- emoji: "CONTROL.BLOCKTICK",
- timestamp: new Date().getTime()
- },
- list: list,
- hidden: {
- guild: interaction.guild.id
- }
+ };
+ if (role) list["role"] = entry(role.id, renderRole(role));
+ if (ping) list["ping"] = entry(ping.id, renderRole(ping));
+ if (channel) list["channel"] = entry(channel.id, renderChannel(channel.id));
+ if (message) list["message"] = entry(message, `\`${message}\``);
+ const data = {
+ meta:{
+ type: "welcomeSettingsUpdated",
+ displayName: "Welcome Settings Changed",
+ calculateType: "nucleusSettingsUpdated",
+ color: NucleusColors.green,
+ emoji: "CONTROL.BLOCKTICK",
+ timestamp: new Date().getTime()
+ },
+ list: list,
+ hidden: {
+ guild: interaction.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
} catch (e) {
- console.log(e)
+ console.log(e);
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Welcome Events")
- .setDescription(`Something went wrong while updating welcome settings`)
+ .setDescription("Something went wrong while updating welcome settings")
.setStatus("Danger")
.setEmoji("GUILD.ROLES.DELETE")
], components: []});
@@ -111,15 +109,15 @@
} else {
return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Welcome Events")
- .setDescription(`No changes were made`)
+ .setDescription("No changes were made")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
], components: []});
}
}
- let lastClicked = null
+ let lastClicked = null;
while (true) {
- let config = await client.database.guilds.read(interaction.guild.id)
+ const config = await client.database.guilds.read(interaction.guild.id);
m = await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Welcome Events")
.setDescription(
@@ -162,47 +160,47 @@
.setDisabled(config.welcome.channel == "dm")
.setStyle("SECONDARY")
])
- ]})
+ ]});
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- break
+ break;
}
- i.deferUpdate()
+ i.deferUpdate();
if (i.customId == "clear-message") {
if (lastClicked == "clear-message") {
await client.database.guilds.write(interaction.guild.id, {"welcome.message": null});
- lastClicked = null
- } else { lastClicked = "clear-message" }
+ lastClicked = null;
+ } else { lastClicked = "clear-message"; }
} else if (i.customId == "clear-role") {
if (lastClicked == "clear-role") {
await client.database.guilds.write(interaction.guild.id, {"welcome.role": null});
- lastClicked = null
- } else { lastClicked = "clear-role" }
+ lastClicked = null;
+ } else { lastClicked = "clear-role"; }
} else if (i.customId == "clear-ping") {
if (lastClicked == "clear-ping") {
await client.database.guilds.write(interaction.guild.id, {"welcome.ping": null});
- lastClicked = null
- } else { lastClicked = "clear-ping" }
+ lastClicked = null;
+ } else { lastClicked = "clear-ping"; }
} else if (i.customId == "clear-channel") {
if (lastClicked == "clear-channel") {
await client.database.guilds.write(interaction.guild.id, {"welcome.channel": null});
- lastClicked = null
- } else { lastClicked = "clear-channel" }
+ lastClicked = null;
+ } else { lastClicked = "clear-channel"; }
} else if (i.customId == "set-channel-dm") {
await client.database.guilds.write(interaction.guild.id, {"welcome.channel": "dm"});
- lastClicked = null
+ lastClicked = null;
}
}
await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as Discord.GuildMember)
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command"
+ const member = (interaction.member as Discord.GuildMember);
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
return true;
-}
+};
export { command };
export { callback };