Fix a bunch of linter errors
diff --git a/src/commands/settings/_meta.ts b/src/commands/settings/_meta.ts
index 63d726e..1241322 100644
--- a/src/commands/settings/_meta.ts
+++ b/src/commands/settings/_meta.ts
@@ -1,4 +1,4 @@
const name = "settings";
const description = "Change bot settings";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 845e001..13cfa89 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,5 +1,10 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton,
+ TextInputComponent
+} from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -12,133 +17,257 @@
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"));
+ .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<void | unknown> => {
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ });
let m;
let clicked = "";
if (interaction.options.getRole("role")) {
const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Moderation Commands")
- .setDescription(keyValueList({
- role: `<@&${interaction.options.getRole("role").id}>`
- }))
+ .setDescription(
+ keyValueList({
+ role: `<@&${interaction.options.getRole("role").id}>`
+ })
+ )
.setColor("Danger")
.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.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});
+ await client.database.guilds.write(interaction.guild.id, {
+ ["moderation.mute.role"]: interaction.options.getRole("role").id
+ });
}
}
while (true) {
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*")
- )
- ], components: [new MessageActionRow().addComponents([
- new MessageButton().setLabel("Warn").setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id")).setCustomId("warn").setStyle("SECONDARY"),
- new MessageButton().setLabel("Mute").setEmoji(getEmojiByName("PUNISH.MUTE.YELLOW", "id")).setCustomId("mute").setStyle("SECONDARY"),
- new MessageButton().setLabel("Nickname").setEmoji(getEmojiByName("PUNISH.NICKNAME.GREEN", "id")).setCustomId("nickname").setStyle("SECONDARY")
- ]), new MessageActionRow().addComponents([
- new MessageButton().setLabel("Kick").setEmoji(getEmojiByName("PUNISH.KICK.RED", "id")).setCustomId("kick").setStyle("SECONDARY"),
- new MessageButton().setLabel("Softban").setEmoji(getEmojiByName("PUNISH.BAN.YELLOW", "id")).setCustomId("softban").setStyle("SECONDARY"),
- new MessageButton().setLabel("Ban").setEmoji(getEmojiByName("PUNISH.BAN.RED", "id")).setCustomId("ban").setStyle("SECONDARY")
- ]), new MessageActionRow().addComponents([
- new MessageButton().setLabel(
- clicked === "clearMuteRole" ? "Click again to confirm" : "Clear mute role"
- ).setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setCustomId("clearMuteRole").setStyle("DANGER").setDisabled(!moderation.mute.role),
- new MessageButton()
- .setCustomId("timeout")
- .setLabel("Mute timeout " + (moderation.mute.timeout ? "Enabled" : "Disabled"))
- .setStyle(moderation.mute.timeout ? "SUCCESS" : "DANGER")
- .setEmoji(getEmojiByName("CONTROL." + (moderation.mute.timeout ? "TICK" : "CROSS"), "id"))
- ])]});
+ 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*")
+ )
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Warn")
+ .setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id"))
+ .setCustomId("warn")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setLabel("Mute")
+ .setEmoji(getEmojiByName("PUNISH.MUTE.YELLOW", "id"))
+ .setCustomId("mute")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setLabel("Nickname")
+ .setEmoji(getEmojiByName("PUNISH.NICKNAME.GREEN", "id"))
+ .setCustomId("nickname")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Kick")
+ .setEmoji(getEmojiByName("PUNISH.KICK.RED", "id"))
+ .setCustomId("kick")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setLabel("Softban")
+ .setEmoji(getEmojiByName("PUNISH.BAN.YELLOW", "id"))
+ .setCustomId("softban")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setLabel("Ban")
+ .setEmoji(getEmojiByName("PUNISH.BAN.RED", "id"))
+ .setCustomId("ban")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(
+ clicked === "clearMuteRole"
+ ? "Click again to confirm"
+ : "Clear mute role"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("clearMuteRole")
+ .setStyle("DANGER")
+ .setDisabled(!moderation.mute.role),
+ new MessageButton()
+ .setCustomId("timeout")
+ .setLabel(
+ "Mute timeout " +
+ (moderation.mute.timeout
+ ? "Enabled"
+ : "Disabled")
+ )
+ .setStyle(
+ moderation.mute.timeout ? "SUCCESS" : "DANGER"
+ )
+ .setEmoji(
+ getEmojiByName(
+ "CONTROL." +
+ (moderation.mute.timeout
+ ? "TICK"
+ : "CROSS"),
+ "id"
+ )
+ )
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return; }
- let chosen = moderation[i.customId] ?? {text: null, url: null};
+ } catch (e) {
+ return;
+ }
+ let chosen = moderation[i.customId] ?? { text: null, url: null };
if (i.component.customId === "clearMuteRole") {
i.deferUpdate();
if (clicked === "clearMuteRole") {
- await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
- } else { clicked = "clearMuteRole"; }
+ await client.database.guilds.write(interaction.guild.id, {
+ "moderation.mute.role": null
+ });
+ } else {
+ clicked = "clearMuteRole";
+ }
continue;
- } else { clicked = ""; }
+ } else {
+ clicked = "";
+ }
if (i.component.customId === "timeout") {
await i.deferUpdate();
- await client.database.guilds.write(interaction.guild.id, {"moderation.mute.timeout": !moderation.mute.timeout } );
+ await client.database.guilds.write(interaction.guild.id, {
+ "moderation.mute.timeout": !moderation.mute.timeout
+ });
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()
- .setCustomId("name")
- .setLabel("Button text")
- .setMaxLength(100)
- .setRequired(false)
- .setStyle("SHORT")
- .setValue(chosen.text ?? "")
- ),
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("url")
- .setLabel("URL - Type {id} to insert the user's ID")
- .setMaxLength(2000)
- .setRequired(false)
- .setStyle("SHORT")
- .setValue(chosen.link ?? "")
- )
- ));
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle(`Options for ${i.customId}`)
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("name")
+ .setLabel("Button text")
+ .setMaxLength(100)
+ .setRequired(false)
+ .setStyle("SHORT")
+ .setValue(chosen.text ?? "")
+ ),
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("url")
+ .setLabel(
+ "URL - Type {id} to insert the user's ID"
+ )
+ .setMaxLength(2000)
+ .setRequired(false)
+ .setStyle("SHORT")
+ .setValue(chosen.link ?? "")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Moderation Links")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("back")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Moderation Links")
+ .setDescription(
+ "Modal opened. If you can't see it, click back and try again."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])
+ ]
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (_) => true);
- } catch (e) { continue; }
+ out = await modalInteractionCollector(
+ m,
+ (m) => m.channel.id === interaction.channel.id,
+ (_) => true
+ );
+ } catch (e) {
+ continue;
+ }
if (out.fields) {
const buttonText = out.fields.getTextInputValue("name");
- const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
+ const buttonLink = out.fields
+ .getTextInputValue("url")
+ .replace(/{id}/gi, "{id}");
const current = chosen;
- if (current.text !== buttonText || current.link !== buttonLink) {
+ 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 }});
+ 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) => {
- 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";
+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 };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/filters.ts b/src/commands/settings/filters.ts
index 7ee5b8d..3b0988e 100644
--- a/src/commands/settings/filters.ts
+++ b/src/commands/settings/filters.ts
@@ -2,20 +2,19 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("filter")
- .setDescription("Setting for message filters");
+ builder.setName("filter").setDescription("Setting for message filters");
const callback = async (_interaction: CommandInteraction): Promise<void> => {
console.log("Filters");
};
const check = (interaction: CommandInteraction) => {
- 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";
+ 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 };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/logs/_meta.ts b/src/commands/settings/logs/_meta.ts
index f46987f..fadff33 100644
--- a/src/commands/settings/logs/_meta.ts
+++ b/src/commands/settings/logs/_meta.ts
@@ -1,4 +1,4 @@
const name = "logs";
const description = "Settings for logging";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index cb96567..f37bd1a 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,6 +1,10 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+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";
@@ -12,39 +16,59 @@
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));
+ .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<void | unknown> => {
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
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")
- ]});
+ 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;
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
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" +
- `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
+ `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
@@ -52,10 +76,13 @@
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;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.attachments.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "attachmentChannelUpdate",
displayName: "Attachment Log Channel Updated",
calculateType: "nucleusSettingsUpdated",
@@ -64,8 +91,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -74,75 +107,124 @@
};
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ "Something went wrong and the attachment log channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription(
- channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel" +
- (client.database.premium.hasPremium(interaction.guild.id) ? "" : "\n\nThis server does not have premium, so this feature is disabled")
- )
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ channel
+ ? `Your attachment log channel is currently set to <#${channel}>`
+ : "This server does not have an attachment log channel" +
+ (client.database.premium.hasPremium(
+ interaction.guild.id
+ )
+ ? ""
+ : "\n\nThis server does not have premium, so this feature is disabled")
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } 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;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription(channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ channel
+ ? `Your attachment log channel is currently set to <#${channel}>`
+ : "This server does not have an attachment log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-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";
+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;
};
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 4d4a392..00d2411 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,6 +1,10 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+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";
@@ -12,47 +16,71 @@
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
- ]));
+ .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<void | unknown> => {
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
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")
- ]});
+ 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;
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
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}>?`)
+ .setDescription(
+ `Are you sure you want to set the log channel to <#${channel.id}>?`
+ )
.setColor("Warning")
.setInverted(true)
.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;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.logs.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "logChannelUpdate",
displayName: "Log Channel Changed",
calculateType: "nucleusSettingsUpdated",
@@ -61,8 +89,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -72,72 +106,119 @@
log(data);
} catch (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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription(
+ "Something went wrong and the log channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.logs.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log channel")
- .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log channel")
+ .setDescription(
+ channel
+ ? `Your log channel is currently set to <#${channel}>`
+ : "This server does not have a log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } 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;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log channel")
- .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log channel")
+ .setDescription(
+ channel
+ ? `Your log channel is currently set to <#${channel}>`
+ : "This server does not have a log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-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";
+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;
};
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 110c70e..a1edcaf 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,33 +1,37 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.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 { toHexArray, toHexInteger } from "../../../utils/calculate.js";
-
const logs = {
- "channelUpdate": "Channels created, deleted or modified",
- "emojiUpdate": "Server emojis modified",
- "stickerUpdate": "Server stickers modified",
- "guildUpdate": "Server settings updated",
- "guildMemberUpdate": "Member updated (i.e. nickname)",
- "guildMemberPunish": "Members punished (i.e. muted, banned, kicked)",
- "guildRoleUpdate": "Role settings changed",
- "guildInviteUpdate": "Server invite created or deleted",
- "messageUpdate": "Message edited",
- "messageDelete": "Message deleted",
- "messageDeleteBulk": "Messages purged",
- "messageReactionUpdate": "Message reactions cleared",
- "messageMassPing": "Message pings multiple members at once",
- "messageAnnounce": "Message published in announcement channel",
- "threadUpdate": "Thread created or deleted",
- "webhookUpdate": "Webhooks created or deleted",
- "guildMemberVerify": "Member runs verify",
- "autoModeratorDeleted": "Messages auto deleted by Nucleus",
- "nucleusSettingsUpdated": "Nucleus' settings updated by a moderator",
- "ticketUpdate": "Tickets created or deleted"
+ channelUpdate: "Channels created, deleted or modified",
+ emojiUpdate: "Server emojis modified",
+ stickerUpdate: "Server stickers modified",
+ guildUpdate: "Server settings updated",
+ guildMemberUpdate: "Member updated (i.e. nickname)",
+ guildMemberPunish: "Members punished (i.e. muted, banned, kicked)",
+ guildRoleUpdate: "Role settings changed",
+ guildInviteUpdate: "Server invite created or deleted",
+ messageUpdate: "Message edited",
+ messageDelete: "Message deleted",
+ messageDeleteBulk: "Messages purged",
+ messageReactionUpdate: "Message reactions cleared",
+ messageMassPing: "Message pings multiple members at once",
+ messageAnnounce: "Message published in announcement channel",
+ threadUpdate: "Thread created or deleted",
+ webhookUpdate: "Webhooks created or deleted",
+ guildMemberVerify: "Member runs verify",
+ autoModeratorDeleted: "Messages auto deleted by Nucleus",
+ nucleusSettingsUpdated: "Nucleus' settings updated by a moderator",
+ ticketUpdate: "Tickets created or deleted"
};
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -36,39 +40,52 @@
.setDescription("Sets what events should be logged");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ });
let m;
while (true) {
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")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu()
- .setPlaceholder("Set events to log")
- .setMaxValues(Object.keys(logs).length)
- .setCustomId("logs")
- .setMinValues(0)
- .setOptions(Object.keys(logs).map((e, i) => ({
- label: logs[e],
- value: i.toString(),
- default: converted.includes(e)
- })))
- ]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Select all")
- .setStyle("PRIMARY")
- .setCustomId("all"),
- new MessageButton()
- .setLabel("Select none")
- .setStyle("DANGER")
- .setCustomId("none")
- ])
- ]});
+ 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"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setPlaceholder("Set events to log")
+ .setMaxValues(Object.keys(logs).length)
+ .setCustomId("logs")
+ .setMinValues(0)
+ .setOptions(
+ Object.keys(logs).map((e, i) => ({
+ label: logs[e],
+ value: i.toString(),
+ default: converted.includes(e)
+ }))
+ )
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Select all")
+ .setStyle("PRIMARY")
+ .setCustomId("all"),
+ new MessageButton()
+ .setLabel("Select none")
+ .setStyle("DANGER")
+ .setCustomId("none")
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
@@ -78,33 +95,50 @@
i.deferUpdate();
if (i.customId === "logs") {
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});
+ 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") {
- const 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;
}
}
- 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")
- .setFooter({text: "Message timed out"})
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ]});
+ 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"
+ )
+ .setFooter({ text: "Message timed out" })
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ]
+ });
return;
};
-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";
+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 };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 2f0c819..718d13b 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,12 +1,16 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+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 type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import type { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
@@ -14,40 +18,62 @@
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));
+ .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<unknown | void> => {
+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>;
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
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")
- ]});
+ 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;
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
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" +
- `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
+ `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
@@ -55,10 +81,13 @@
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;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.staff.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "staffChannelUpdate",
displayName: "Staff Notifications Channel Updated",
calculateType: "nucleusSettingsUpdated",
@@ -67,8 +96,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -77,72 +112,119 @@
};
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription(
+ "Something went wrong and the staff notifications channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications channel")
+ .setDescription(
+ channel
+ ? `Your staff notifications channel is currently set to <#${channel}>`
+ : "This server does not have a staff notifications channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } 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;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications channel")
+ .setDescription(
+ channel
+ ? `Your staff notifications channel is currently set to <#${channel}>`
+ : "This server does not have a staff notifications channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-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";
+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;
};
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 9a4ceb0..beb2f35 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -5,20 +5,28 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("rolemenu")
- .setDescription("rolemenu")// TODO
- .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")); // FIXME FOR FUCK SAKE
+ .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<void> => {
console.log("we changed the charger again because fuck you");
await interaction.reply("You're mum");
};
-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";
+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 };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 5a1affd..507e506 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,62 +1,112 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Message, MessageActionRow, MessageSelectMenu } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ Message,
+ 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 {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
+import { callback as statsChannelAddCallback } from "../../reflex/statsChannelUpdate.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));
+ .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<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
singleNotify("statsChannelDeleted", interaction.guild.id, true);
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Message;
let config = await client.database.guilds.read(interaction.guild.id);
if (interaction.options.getString("name")) {
let channel;
if (Object.keys(config.getKey("stats")).length >= 25) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Stats Channel")
- .setDescription("You can only have 25 stats channels in a server")
- .setStatus("Danger")
- ]});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Stats Channel")
+ .setDescription(
+ "You can only have 25 stats channels in a server"
+ )
+ .setStatus("Danger")
+ ]
+ });
}
try {
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")
- ]});
+ 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;
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats Channel")
+ .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, "-");
}
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, "")}*`)
+ .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);
@@ -65,10 +115,13 @@
try {
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;
+ await client.database.guilds.write(interaction.guild.id, {
+ [`stats.${channel.id}`]: { name: name, enabled: true }
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "statsChannelUpdate",
displayName: "Stats Channel Updated",
calculateType: "nucleusSettingsUpdated",
@@ -77,10 +130,19 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ 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")}\``)
+ name: entry(
+ interaction.options.getString("name"),
+ `\`${interaction.options.getString("name")}\``
+ )
},
hidden: {
guild: interaction.guild.id
@@ -89,20 +151,30 @@
log(data);
} catch (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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats Channel")
+ .setDescription(
+ "Something went wrong and the stats channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
await statsChannelAddCallback(client, interaction.member);
}
@@ -113,41 +185,83 @@
.setCustomId("remove")
.setMinValues(1)
.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.")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [
- new MessageActionRow().addComponents(Object.keys(stats).length ? [
- 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}`
- })))
- ] : [selectMenu.setPlaceholder("The server has no stats channels").setDisabled(true).setOptions([
- {label: "*Placeholder*", value: "placeholder", description: "No stats channels"}
- ])])
- ]});
+ 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."
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents(
+ Object.keys(stats).length
+ ? [
+ 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}`
+ }))
+ )
+ ]
+ : [
+ 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; }
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
if (i.customId === "remove") {
const toRemove = i.values;
- await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
+ await client.database.guilds.write(
+ interaction.guild.id,
+ null,
+ toRemove.map((k) => `stats.${k}`)
+ );
}
}
- await interaction.editReply({embeds: [(m.embeds[0] as Discord.MessageEmbed).setFooter({text: "Message closed"})], components: []});
+ await interaction.editReply({
+ embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })],
+ components: []
+ });
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- 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";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ 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 };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index f9df71c..5e5cbe7 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -2,103 +2,198 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import Discord, { CommandInteraction, GuildChannel, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import Discord, {
+ CommandInteraction,
+ GuildChannel,
+ Message,
+ MessageActionRow,
+ MessageActionRowComponent,
+ MessageButton,
+ MessageComponentInteraction,
+ MessageSelectMenu,
+ Role,
+ SelectMenuInteraction,
+ TextInputComponent
+} from "discord.js";
+import {
+ SelectMenuOption,
+ SlashCommandSubcommandBuilder
+} from "@discordjs/builders";
import { ChannelType } from "discord-api-types";
import client from "../../utils/client.js";
-import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
+import {
+ toHexInteger,
+ toHexArray,
+ tickets as ticketTypes
+} from "../../utils/calculate.js";
import { capitalize } from "../../utils/generateKeyValueList.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
-import {GuildConfig} from "../../utils/database.js";
+import { GuildConfig } from "../../utils/database.js";
-const command = (builder: SlashCommandSubcommandBuilder) => builder
- .setName("tickets")
- .setDescription("Shows settings for tickets | Use no arguments to manage custom types")
- .addStringOption(option => option.setName("enabled").setDescription("If users should be able to create tickets").setRequired(false)
- .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));
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder
+ .setName("tickets")
+ .setDescription(
+ "Shows settings for tickets | Use no arguments to manage custom types"
+ )
+ .addStringOption((option) =>
+ option
+ .setName("enabled")
+ .setDescription("If users should be able to create tickets")
+ .setRequired(false)
+ .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)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- let m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ let m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Message;
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")
};
- if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
+ if (
+ options.enabled !== null ||
+ options.category ||
+ options.maxtickets ||
+ options.supportping
+ ) {
options.enabled = options.enabled === "yes" ? true : false;
if (options.category) {
let channel: GuildChannel;
try {
- channel = await interaction.guild.channels.fetch(options.category.id);
+ channel = await interaction.guild.channels.fetch(
+ options.category.id
+ );
} catch {
return await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Tickets > Category")
- .setDescription("The channel you provided is not a valid category")
- .setStatus("Danger")
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Tickets > Category")
+ .setDescription(
+ "The channel you provided is not a valid category"
+ )
+ .setStatus("Danger")
]
});
}
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")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]
- });
+ 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"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
if (options.maxtickets) {
- if (options.maxtickets < 1) return interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Tickets > Max Tickets")
- .setDescription("You must choose a number greater than 0")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]
- });
+ if (options.maxtickets < 1)
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets > Max Tickets")
+ .setDescription(
+ "You must choose a number greater than 0"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
let role: Role;
if (options.supportping) {
try {
- role = await interaction.guild.roles.fetch(options.supportping.id);
+ role = await interaction.guild.roles.fetch(
+ options.supportping.id
+ );
} catch {
return await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("GUILD.ROLE.DELETE")
- .setTitle("Tickets > Support Ping")
- .setDescription("The role you provided is not a valid role")
- .setStatus("Danger")
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("GUILD.ROLE.DELETE")
+ .setTitle("Tickets > Support Ping")
+ .setDescription(
+ "The role you provided is not a valid role"
+ )
+ .setStatus("Danger")
]
});
}
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")
- .setStatus("Danger")
- .setEmoji("GUILD.ROLE.DELETE")
- ]
- });
+ 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"
+ )
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLE.DELETE")
+ ]
+ });
}
const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.TICKET.ARCHIVED")
.setTitle("Tickets")
.setDescription(
- (options.category ? `**Category:** ${options.category.name}\n` : "") +
- (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?"
+ (options.category
+ ? `**Category:** ${options.category.name}\n`
+ : "") +
+ (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?"
)
.setColor("Warning")
.setInverted(true)
@@ -106,35 +201,51 @@
if (confirmation.cancelled) return;
if (confirmation.success) {
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;
+ 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")
- .setStatus("Danger")
- .setEmoji("GUILD.TICKET.DELETE")
- ], components: []
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets")
+ .setDescription(
+ "Something went wrong and the staff notifications channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("GUILD.TICKET.DELETE")
+ ],
+ components: []
});
}
} else {
return interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Tickets")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: []
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: []
});
}
}
let data = await client.database.guilds.read(interaction.guild.id);
- data.tickets.customTypes = (data.tickets.customTypes || []).filter((value: string, index: number, array: string[]) => array.indexOf(value) === index);
+ data.tickets.customTypes = (data.tickets.customTypes || []).filter(
+ (value: string, index: number, array: string[]) =>
+ array.indexOf(value) === index
+ );
let lastClicked = "";
let embed: EmojiEmbed;
data = {
@@ -150,235 +261,449 @@
embed = new EmojiEmbed()
.setTitle("Tickets")
.setDescription(
- `${data.enabled ? "" : getEmojiByName("TICKETS.REPORT")} **Enabled:** ${data.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`}\n` +
- `${data.category ? "" : getEmojiByName("TICKETS.REPORT")} **Category:** ${data.category ? `<#${data.category}>` : "*None set*"}\n` +
- `**Max Tickets:** ${data.maxTickets ? data.maxTickets : "*No limit*"}\n` +
- `**Support Ping:** ${data.supportRole ? `<@&${data.supportRole}>` : "*None set*"}\n\n` +
- ((data.useCustom && data.customTypes === null) ? `${getEmojiByName("TICKETS.REPORT")} ` : "") +
- `${data.useCustom ? "Custom" : "Default"} types in use` + "\n\n" +
- `${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
+ `${
+ data.enabled ? "" : getEmojiByName("TICKETS.REPORT")
+ } **Enabled:** ${
+ data.enabled
+ ? `${getEmojiByName("CONTROL.TICK")} Yes`
+ : `${getEmojiByName("CONTROL.CROSS")} No`
+ }\n` +
+ `${
+ data.category ? "" : getEmojiByName("TICKETS.REPORT")
+ } **Category:** ${
+ data.category ? `<#${data.category}>` : "*None set*"
+ }\n` +
+ `**Max Tickets:** ${
+ data.maxTickets ? data.maxTickets : "*No limit*"
+ }\n` +
+ `**Support Ping:** ${
+ data.supportRole
+ ? `<@&${data.supportRole}>`
+ : "*None set*"
+ }\n\n` +
+ (data.useCustom && data.customTypes === null
+ ? `${getEmojiByName("TICKETS.REPORT")} `
+ : "") +
+ `${data.useCustom ? "Custom" : "Default"} types in use` +
+ "\n\n" +
+ `${getEmojiByName(
+ "TICKETS.REPORT"
+ )} *Indicates a setting stopping tickets from being used*`
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN");
- m = await interaction.editReply({
- embeds: [embed], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Tickets " + (data.enabled ? "enabled" : "disabled"))
- .setEmoji(getEmojiByName("CONTROL." + (data.enabled ? "TICK" : "CROSS"), "id"))
- .setStyle(data.enabled ? "SUCCESS" : "DANGER")
- .setCustomId("enabled"),
- new MessageButton()
- .setLabel(lastClicked === "cat" ? "Click again to confirm" : "Clear category")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setCustomId("clearCategory")
- .setDisabled(data.category === null),
- new MessageButton()
- .setLabel(lastClicked === "max" ? "Click again to confirm" : "Reset max tickets")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setCustomId("clearMaxTickets")
- .setDisabled(data.maxTickets === 5),
- new MessageButton()
- .setLabel(lastClicked === "sup" ? "Click again to confirm" : "Clear support ping")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setCustomId("clearSupportPing")
- .setDisabled(data.supportRole === null)
- ]), new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Manage types")
- .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
- .setStyle("SECONDARY")
- .setCustomId("manageTypes"),
- new MessageButton()
- .setLabel("Add create ticket button")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
- .setStyle("PRIMARY")
- .setCustomId("send")
- ])]
- }) as Message;
+ m = (await interaction.editReply({
+ embeds: [embed],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(
+ "Tickets " + (data.enabled ? "enabled" : "disabled")
+ )
+ .setEmoji(
+ getEmojiByName(
+ "CONTROL." + (data.enabled ? "TICK" : "CROSS"),
+ "id"
+ )
+ )
+ .setStyle(data.enabled ? "SUCCESS" : "DANGER")
+ .setCustomId("enabled"),
+ new MessageButton()
+ .setLabel(
+ lastClicked === "cat"
+ ? "Click again to confirm"
+ : "Clear category"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setCustomId("clearCategory")
+ .setDisabled(data.category === null),
+ new MessageButton()
+ .setLabel(
+ lastClicked === "max"
+ ? "Click again to confirm"
+ : "Reset max tickets"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setCustomId("clearMaxTickets")
+ .setDisabled(data.maxTickets === 5),
+ new MessageButton()
+ .setLabel(
+ lastClicked === "sup"
+ ? "Click again to confirm"
+ : "Clear support ping"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setCustomId("clearSupportPing")
+ .setDisabled(data.supportRole === null)
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Manage types")
+ .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("manageTypes"),
+ new MessageButton()
+ .setLabel("Add create ticket button")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("send")
+ ])
+ ]
+ })) as Message;
let i: MessageComponentInteraction;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break; }
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
- if ((i.component as MessageActionRowComponent).customId === "clearCategory") {
+ if (
+ (i.component as MessageActionRowComponent).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 as MessageActionRowComponent).customId === "clearMaxTickets") {
+ } else if (
+ (i.component as MessageActionRowComponent).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 as MessageActionRowComponent).customId === "clearSupportPing") {
+ } else if (
+ (i.component as MessageActionRowComponent).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 as MessageActionRowComponent).customId === "send") {
+ } else if (
+ (i.component as MessageActionRowComponent).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: "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"
+ }
];
while (true) {
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")
- .setFooter({text: enabled ? "" : "Tickets are not set up correctly so the button may not work for users. Check the main menu to find which options must be set."})
- .setStatus(enabled ? "Success" : "Warning")
- .setEmoji("GUILD.ROLES.CREATE")
- ], 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")
- ]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("back")
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("DANGER"),
- new MessageButton()
- .setCustomId("blank")
- .setLabel("Empty")
- .setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("custom")
- .setLabel("Custom")
- .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
- .setStyle("PRIMARY")
- ])
- ]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Ticket Button")
+ .setDescription(
+ "Select a message template to send in this channel"
+ )
+ .setFooter({
+ text: enabled
+ ? ""
+ : "Tickets are not set up correctly so the button may not work for users. Check the main menu to find which options must be set."
+ })
+ .setStatus(enabled ? "Success" : "Warning")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ 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")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setCustomId("blank")
+ .setLabel("Empty")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("custom")
+ .setLabel("Custom")
+ .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+ .setStyle("PRIMARY")
+ ])
+ ]
+ });
let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
- if ((i.component as MessageActionRowComponent).customId === "template") {
- i.deferUpdate();
- await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
- .setDescription(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Create Ticket")
- .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
- .setStyle("SUCCESS")
- .setCustomId("createticket")
- ])]});
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
break;
- } else if ((i.component as MessageActionRowComponent).customId === "blank") {
+ }
+ if (
+ (i.component as MessageActionRowComponent).customId ===
+ "template"
+ ) {
i.deferUpdate();
- await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Create Ticket")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
- .setStyle("SUCCESS")
- .setCustomId("createticket")
- ])]});
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(
+ ticketMessages[
+ parseInt(
+ (i as SelectMenuInteraction)
+ .values[0]
+ )
+ ].label
+ )
+ .setDescription(
+ ticketMessages[
+ parseInt(
+ (i as SelectMenuInteraction)
+ .values[0]
+ )
+ ].description
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Create Ticket")
+ .setEmoji(
+ getEmojiByName("CONTROL.TICK", "id")
+ )
+ .setStyle("SUCCESS")
+ .setCustomId("createticket")
+ ])
+ ]
+ });
break;
- } else if ((i.component as MessageActionRowComponent).customId === "custom") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("title")
- .setLabel("Title")
- .setMaxLength(256)
- .setRequired(true)
- .setStyle("SHORT")
- ),
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("description")
- .setLabel("Description")
- .setMaxLength(4000)
- .setRequired(true)
- .setStyle("PARAGRAPH")
- )
- ));
+ } else if (
+ (i.component as MessageActionRowComponent).customId ===
+ "blank"
+ ) {
+ 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;
+ } else if (
+ (i.component as MessageActionRowComponent).customId ===
+ "custom"
+ ) {
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle("Enter embed details")
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("title")
+ .setLabel("Title")
+ .setMaxLength(256)
+ .setRequired(true)
+ .setStyle("SHORT")
+ ),
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("description")
+ .setLabel("Description")
+ .setMaxLength(4000)
+ .setRequired(true)
+ .setStyle("PARAGRAPH")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Ticket Button")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("back")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Ticket Button")
+ .setDescription(
+ "Modal opened. If you can't see it, click back and try again."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Back")
+ .setEmoji(
+ getEmojiByName("CONTROL.LEFT", "id")
+ )
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])
+ ]
});
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) {
const title = out.fields.getTextInputValue("title");
- const description = out.fields.getTextInputValue("description");
- await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(title)
- .setDescription(description)
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Create Ticket")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
- .setStyle("SUCCESS")
- .setCustomId("createticket")
- ])]});
+ const description =
+ out.fields.getTextInputValue("description");
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(title)
+ .setDescription(description)
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Create Ticket")
+ .setEmoji(
+ getEmojiByName(
+ "TICKETS.SUGGESTION",
+ "id"
+ )
+ )
+ .setStyle("SUCCESS")
+ .setCustomId("createticket")
+ ])
+ ]
+ });
break;
- } else { continue; }
+ } else {
+ continue;
+ }
}
}
- } else if ((i.component as MessageActionRowComponent).customId === "enabled") {
- await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled });
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "enabled"
+ ) {
+ await client.database.guilds.write(interaction.guild.id, {
+ "tickets.enabled": !data.enabled
+ });
data.enabled = !data.enabled;
- } else if ((i.component as MessageActionRowComponent).customId === "manageTypes") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId ===
+ "manageTypes"
+ ) {
data = await manageTypes(interaction, data, m as Message);
} else {
break;
}
}
- await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
+ await interaction.editReply({
+ embeds: [embed.setFooter({ text: "Message closed" })],
+ components: []
+ });
};
-async function manageTypes(interaction: CommandInteraction, data: GuildConfig["tickets"], m: Message) {
+async function manageTypes(
+ interaction: CommandInteraction,
+ data: GuildConfig["tickets"],
+ m: Message
+) {
while (true) {
if (data.useCustom) {
const customTypes = data.customTypes;
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Tickets > Types")
- .setDescription(
- "**Custom types enabled**\n\n" +
- "**Types in use:**\n" + ((customTypes !== null) ?
- (customTypes.map((t) => `> ${t}`).join("\n")) :
- "*None set*"
- ) + "\n\n" + (customTypes === null ?
- `${getEmojiByName("TICKETS.REPORT")} Having no types will disable tickets. Please add at least 1 type or use default types` : ""
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets > Types")
+ .setDescription(
+ "**Custom types enabled**\n\n" +
+ "**Types in use:**\n" +
+ (customTypes !== null
+ ? customTypes
+ .map((t) => `> ${t}`)
+ .join("\n")
+ : "*None set*") +
+ "\n\n" +
+ (customTypes === null
+ ? `${getEmojiByName(
+ "TICKETS.REPORT"
+ )} Having no types will disable tickets. Please add at least 1 type or use default types`
+ : "")
)
- )
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: (customTypes ? [
- new MessageActionRow().addComponents([new Discord.MessageSelectMenu()
- .setCustomId("removeTypes")
- .setPlaceholder("Select types to remove")
- .setMaxValues(customTypes.length)
- .setMinValues(1)
- .addOptions(customTypes.map((t) => ({
- label: t,
- value: t
- })))
- ])
- ] : []).concat([
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: (customTypes
+ ? [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .setCustomId("removeTypes")
+ .setPlaceholder("Select types to remove")
+ .setMaxValues(customTypes.length)
+ .setMinValues(1)
+ .addOptions(
+ customTypes.map((t) => ({
+ label: t,
+ value: t
+ }))
+ )
+ ])
+ ]
+ : []
+ ).concat([
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Back")
@@ -387,10 +712,14 @@
.setCustomId("back"),
new MessageButton()
.setLabel("Add new type")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+ .setEmoji(
+ getEmojiByName("TICKETS.SUGGESTION", "id")
+ )
.setStyle("PRIMARY")
.setCustomId("addType")
- .setDisabled(customTypes !== null && customTypes.length >= 25),
+ .setDisabled(
+ customTypes !== null && customTypes.length >= 25
+ ),
new MessageButton()
.setLabel("Switch to default types")
.setStyle("SECONDARY")
@@ -401,13 +730,20 @@
} else {
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)
- }));
+ 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)
+ })
+ );
});
const selectPane = new MessageActionRow().addComponents([
new Discord.MessageSelectMenu()
@@ -418,16 +754,25 @@
.setPlaceholder("Select types to use")
]);
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Tickets > Types")
- .setDescription(
- "**Default types enabled**\n\n" +
- "**Types in use:**\n" +
- (inUse.map((t) => `> ${getEmojiByName("TICKETS." + t.toUpperCase())} ${capitalize(t)}`).join("\n"))
- )
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets > Types")
+ .setDescription(
+ "**Default types enabled**\n\n" +
+ "**Types in use:**\n" +
+ inUse
+ .map(
+ (t) =>
+ `> ${getEmojiByName(
+ "TICKETS." + t.toUpperCase()
+ )} ${capitalize(t)}`
+ )
+ .join("\n")
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
selectPane,
new MessageActionRow().addComponents([
new MessageButton()
@@ -446,11 +791,15 @@
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { break; }
+ } catch (e) {
+ break;
+ }
if (i.component.customId === "types") {
i.deferUpdate();
const types = toHexInteger(i.values, ticketTypes);
- await client.database.guilds.write(interaction.guild.id, { "tickets.types": types });
+ await client.database.guilds.write(interaction.guild.id, {
+ "tickets.types": types
+ });
data.types = types;
} else if (i.component.customId === "removeTypes") {
i.deferUpdate();
@@ -459,57 +808,96 @@
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") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter a name for the new type").addComponents(
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("type")
- .setLabel("Name")
- .setMaxLength(100)
- .setMinLength(1)
- .setPlaceholder("E.g. \"Server Idea\"")
- .setRequired(true)
- .setStyle("SHORT")
- )
- ));
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle("Enter a name for the new type")
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("type")
+ .setLabel("Name")
+ .setMaxLength(100)
+ .setMinLength(1)
+ .setPlaceholder('E.g. "Server Idea"')
+ .setRequired(true)
+ .setStyle("SHORT")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Tickets > Types")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("back")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tickets > Types")
+ .setDescription(
+ "Modal opened. If you can't see it, click back and try again."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])
+ ]
});
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; }
+ 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 }, []);
+ 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 }, []);
+ await client.database.guilds.write(
+ interaction.guild.id,
+ { "tickets.useCustom": true },
+ []
+ );
data.useCustom = true;
} else {
i.deferUpdate();
@@ -519,10 +907,10 @@
return data;
}
-
const check = (interaction: CommandInteraction) => {
- 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";
+ 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;
};
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 4efd68c..e0af802 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,5 +1,17 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageEmbed, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ Message,
+ MessageActionRow,
+ MessageActionRowComponent,
+ MessageButton,
+ MessageComponentInteraction,
+ MessageEmbed,
+ MessageSelectMenu,
+ Role,
+ SelectMenuInteraction,
+ TextInputComponent
+} from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -11,45 +23,70 @@
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));
+ .addRoleOption((option) =>
+ option
+ .setName("role")
+ .setDescription("The role to give after verifying")
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Message;
if (interaction.options.getRole("role")) {
let role: Role;
try {
role = interaction.options.getRole("role") as 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")
- ]});
+ 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;
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")
- .setStatus("Danger")
- .setEmoji("GUILD.ROLES.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription("You must choose a role in this server")
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLES.DELETE")
+ ]
+ });
}
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}>?`)
+ .setDescription(
+ `Are you sure you want to set the verify role to <@&${role.id}>?`
+ )
.setColor("Warning")
.setInverted(true)
.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;
+ await client.database.guilds.write(interaction.guild.id, {
+ "verify.role": role.id,
+ "verify.enabled": true
+ });
+ const { log, NucleusColors, entry, renderUser, renderRole } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "verifyRoleChanged",
displayName: "Verify Role Changed",
calculateType: "nucleusSettingsUpdated",
@@ -58,8 +95,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
role: entry(role.id, renderRole(role))
},
hidden: {
@@ -69,169 +112,319 @@
log(data);
} catch (e) {
console.log(e);
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Verify Role")
- .setDescription("Something went wrong while setting the verify role")
- .setStatus("Danger")
- .setEmoji("GUILD.ROLES.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(
+ "Something went wrong while setting the verify role"
+ )
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLES.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Verify Role")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
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")
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset role")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!role),
- new MessageButton()
- .setCustomId("send")
- .setLabel("Add verify button")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
- .setStyle("PRIMARY")
- ])]});
+ 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"
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset role"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!role),
+ new MessageButton()
+ .setCustomId("send")
+ .setLabel("Add verify button")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+ .setStyle("PRIMARY")
+ ])
+ ]
+ });
let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
if ((i.component as MessageActionRowComponent).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 as MessageActionRowComponent).customId === "send") {
+ } else if (
+ (i.component as MessageActionRowComponent).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: "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"
+ }
];
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Verify Button")
- .setDescription("Select a message template to send in this channel")
- .setFooter({text: role ? "" : "You do no have a verify role set so the button will not work."})
- .setStatus(role ? "Success" : "Warning")
- .setEmoji("GUILD.ROLES.CREATE")
- ], 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")
- ]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("back")
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("DANGER"),
- new MessageButton()
- .setCustomId("blank")
- .setLabel("Empty")
- .setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("custom")
- .setLabel("Custom")
- .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
- .setStyle("PRIMARY")
- ])
- ]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Verify Button")
+ .setDescription(
+ "Select a message template to send in this channel"
+ )
+ .setFooter({
+ text: role
+ ? ""
+ : "You do no have a verify role set so the button will not work."
+ })
+ .setStatus(role ? "Success" : "Warning")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ 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")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setCustomId("blank")
+ .setLabel("Empty")
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("custom")
+ .setLabel("Custom")
+ .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+ .setStyle("PRIMARY")
+ ])
+ ]
+ });
let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
- if ((i.component as MessageActionRowComponent).customId === "template") {
- i.deferUpdate();
- await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
- .setDescription(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
- .setStatus("Success")
- .setEmoji("CONTROL.BLOCKTICK")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Verify")
- .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
- .setStyle("SUCCESS")
- .setCustomId("verifybutton")
- ])]});
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
break;
- } else if ((i.component as MessageActionRowComponent).customId === "blank") {
+ }
+ if (
+ (i.component as MessageActionRowComponent).customId ===
+ "template"
+ ) {
i.deferUpdate();
- await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Verify")
- .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
- .setStyle("SUCCESS")
- .setCustomId("verifybutton")
- ])]});
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(
+ verifyMessages[
+ parseInt(
+ (i as SelectMenuInteraction)
+ .values[0]
+ )
+ ].label
+ )
+ .setDescription(
+ verifyMessages[
+ parseInt(
+ (i as SelectMenuInteraction)
+ .values[0]
+ )
+ ].description
+ )
+ .setStatus("Success")
+ .setEmoji("CONTROL.BLOCKTICK")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Verify")
+ .setEmoji(
+ getEmojiByName("CONTROL.TICK", "id")
+ )
+ .setStyle("SUCCESS")
+ .setCustomId("verifybutton")
+ ])
+ ]
+ });
break;
- } else if ((i.component as MessageActionRowComponent).customId === "custom") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("title")
- .setLabel("Title")
- .setMaxLength(256)
- .setRequired(true)
- .setStyle("SHORT")
- ),
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("description")
- .setLabel("Description")
- .setMaxLength(4000)
- .setRequired(true)
- .setStyle("PARAGRAPH")
- )
- ));
+ } else if (
+ (i.component as MessageActionRowComponent).customId ===
+ "blank"
+ ) {
+ i.deferUpdate();
+ await interaction.channel.send({
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Verify")
+ .setEmoji(
+ getEmojiByName("CONTROL.TICK", "id")
+ )
+ .setStyle("SUCCESS")
+ .setCustomId("verifybutton")
+ ])
+ ]
+ });
+ break;
+ } else if (
+ (i.component as MessageActionRowComponent).customId ===
+ "custom"
+ ) {
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle("Enter embed details")
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("title")
+ .setLabel("Title")
+ .setMaxLength(256)
+ .setRequired(true)
+ .setStyle("SHORT")
+ ),
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("description")
+ .setLabel("Description")
+ .setMaxLength(4000)
+ .setRequired(true)
+ .setStyle("PARAGRAPH")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Verify Button")
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("back")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Verify Button")
+ .setDescription(
+ "Modal opened. If you can't see it, click back and try again."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Back")
+ .setEmoji(
+ getEmojiByName("CONTROL.LEFT", "id")
+ )
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])
+ ]
});
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) {
const title = out.fields.getTextInputValue("title");
- const description = out.fields.getTextInputValue("description");
- await interaction.channel.send({embeds: [new EmojiEmbed()
- .setTitle(title)
- .setDescription(description)
- .setStatus("Success")
- .setEmoji("CONTROL.BLOCKTICK")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Verify")
- .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
- .setStyle("SUCCESS")
- .setCustomId("verifybutton")
- ])]});
+ const description =
+ out.fields.getTextInputValue("description");
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(title)
+ .setDescription(description)
+ .setStatus("Success")
+ .setEmoji("CONTROL.BLOCKTICK")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Verify")
+ .setEmoji(
+ getEmojiByName("CONTROL.TICK", "id")
+ )
+ .setStyle("SUCCESS")
+ .setCustomId("verifybutton")
+ ])
+ ]
+ });
break;
- } else { continue; }
+ } else {
+ continue;
+ }
}
}
} else {
@@ -239,12 +432,16 @@
break;
}
}
- await interaction.editReply({embeds: [(m.embeds[0] as MessageEmbed).setFooter({text: "Message closed"})], components: []});
+ await interaction.editReply({
+ embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })],
+ components: []
+ });
};
const check = (interaction: CommandInteraction) => {
- 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";
+ 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;
};
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index f22f409..3eb0ec5 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -1,5 +1,13 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { Channel, CommandInteraction, Message, MessageActionRow, MessageButton, MessageComponentInteraction, Role } from "discord.js";
+import Discord, {
+ Channel,
+ CommandInteraction,
+ Message,
+ MessageActionRow,
+ MessageButton,
+ MessageComponentInteraction,
+ Role
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -11,19 +19,52 @@
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
- ]));
+ .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<void | unknown> => {
- const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
- await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } =
+ client.logger;
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ });
let m: Message;
- if (interaction.options.getRole("role") || interaction.options.getChannel("channel") || interaction.options.getString("message")) {
+ if (
+ interaction.options.getRole("role") ||
+ interaction.options.getChannel("channel") ||
+ interaction.options.getString("message")
+ ) {
let role: Role;
let ping: Role;
const message = interaction.options.getString("message");
@@ -31,32 +72,42 @@
role = interaction.options.getRole("role") as Role;
ping = interaction.options.getRole("ping") as Role;
} 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")
- ]});
+ 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: Channel;
try {
channel = interaction.options.getChannel("channel") as 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")
- ]});
+ 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;
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;
+ 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")
@@ -72,17 +123,27 @@
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);
+ await client.database.guilds.write(
+ interaction.guild.id,
+ toChange
+ );
const list = {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user))
+ 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}\``);
+ 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:{
+ meta: {
type: "welcomeSettingsUpdated",
displayName: "Welcome Settings Changed",
calculateType: "nucleusSettingsUpdated",
@@ -98,68 +159,128 @@
log(data);
} catch (e) {
console.log(e);
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Welcome Events")
- .setDescription("Something went wrong while updating welcome settings")
- .setStatus("Danger")
- .setEmoji("GUILD.ROLES.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Welcome Events")
+ .setDescription(
+ "Something went wrong while updating welcome settings"
+ )
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLES.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Welcome Events")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Welcome Events")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ components: []
+ });
}
}
let lastClicked = null;
while (true) {
const config = await client.database.guilds.read(interaction.guild.id);
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Welcome Events")
- .setDescription(
- `**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` +
- `**Role:** ${config.welcome.role ? renderRole(await interaction.guild.roles.fetch(config.welcome.role)) : "*None set*"}\n` +
- `**Ping:** ${config.welcome.ping ? renderRole(await interaction.guild.roles.fetch(config.welcome.ping)) : "*None set*"}\n` +
- `**Channel:** ${config.welcome.channel ? (config.welcome.channel == "dm" ? "DM" : renderChannel(await interaction.guild.channels.fetch(config.welcome.channel))) : "*None set*"}`
- )
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel(lastClicked == "clear-message" ? "Click again to confirm" : "Clear Message")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("clear-message")
- .setDisabled(!config.welcome.message)
- .setStyle("DANGER"),
- new MessageButton()
- .setLabel(lastClicked == "clear-role" ? "Click again to confirm" : "Clear Role")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("clear-role")
- .setDisabled(!config.welcome.role)
- .setStyle("DANGER"),
- new MessageButton()
- .setLabel(lastClicked == "clear-ping" ? "Click again to confirm" : "Clear Ping")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("clear-ping")
- .setDisabled(!config.welcome.ping)
- .setStyle("DANGER"),
- new MessageButton()
- .setLabel(lastClicked == "clear-channel" ? "Click again to confirm" : "Clear Channel")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("clear-channel")
- .setDisabled(!config.welcome.channel)
- .setStyle("DANGER"),
- new MessageButton()
- .setLabel("Set Channel to DM")
- .setCustomId("set-channel-dm")
- .setDisabled(config.welcome.channel == "dm")
- .setStyle("SECONDARY")
- ])
- ]}) as Message;
+ m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Welcome Events")
+ .setDescription(
+ `**Message:** ${
+ config.welcome.message
+ ? `\n> ${config.welcome.message}`
+ : "*None set*"
+ }\n` +
+ `**Role:** ${
+ config.welcome.role
+ ? renderRole(
+ await interaction.guild.roles.fetch(
+ config.welcome.role
+ )
+ )
+ : "*None set*"
+ }\n` +
+ `**Ping:** ${
+ config.welcome.ping
+ ? renderRole(
+ await interaction.guild.roles.fetch(
+ config.welcome.ping
+ )
+ )
+ : "*None set*"
+ }\n` +
+ `**Channel:** ${
+ config.welcome.channel
+ ? config.welcome.channel == "dm"
+ ? "DM"
+ : renderChannel(
+ await interaction.guild.channels.fetch(
+ config.welcome.channel
+ )
+ )
+ : "*None set*"
+ }`
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(
+ lastClicked == "clear-message"
+ ? "Click again to confirm"
+ : "Clear Message"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("clear-message")
+ .setDisabled(!config.welcome.message)
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setLabel(
+ lastClicked == "clear-role"
+ ? "Click again to confirm"
+ : "Clear Role"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("clear-role")
+ .setDisabled(!config.welcome.role)
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setLabel(
+ lastClicked == "clear-ping"
+ ? "Click again to confirm"
+ : "Clear Ping"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("clear-ping")
+ .setDisabled(!config.welcome.ping)
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setLabel(
+ lastClicked == "clear-channel"
+ ? "Click again to confirm"
+ : "Clear Channel"
+ )
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("clear-channel")
+ .setDisabled(!config.welcome.channel)
+ .setStyle("DANGER"),
+ new MessageButton()
+ .setLabel("Set Channel to DM")
+ .setCustomId("set-channel-dm")
+ .setDisabled(config.welcome.channel == "dm")
+ .setStyle("SECONDARY")
+ ])
+ ]
+ })) as Message;
let i: MessageComponentInteraction;
try {
i = await m.awaitMessageComponent({ time: 300000 });
@@ -169,35 +290,57 @@
i.deferUpdate();
if (i.customId == "clear-message") {
if (lastClicked == "clear-message") {
- await client.database.guilds.write(interaction.guild.id, {"welcome.message": null});
+ await client.database.guilds.write(interaction.guild.id, {
+ "welcome.message": null
+ });
lastClicked = null;
- } else { lastClicked = "clear-message"; }
+ } 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});
+ await client.database.guilds.write(interaction.guild.id, {
+ "welcome.role": null
+ });
lastClicked = null;
- } else { lastClicked = "clear-role"; }
+ } 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});
+ await client.database.guilds.write(interaction.guild.id, {
+ "welcome.ping": null
+ });
lastClicked = null;
- } else { lastClicked = "clear-ping"; }
+ } 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});
+ await client.database.guilds.write(interaction.guild.id, {
+ "welcome.channel": null
+ });
lastClicked = null;
- } else { lastClicked = "clear-channel"; }
+ } else {
+ lastClicked = "clear-channel";
+ }
} else if (i.customId == "set-channel-dm") {
- await client.database.guilds.write(interaction.guild.id, {"welcome.channel": "dm"});
+ await client.database.guilds.write(interaction.guild.id, {
+ "welcome.channel": "dm"
+ });
lastClicked = null;
}
}
- await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
+ await interaction.editReply({
+ embeds: [m.embeds[0].setFooter({ text: "Message closed" })],
+ components: []
+ });
};
const check = (interaction: CommandInteraction) => {
- 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";
+ 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;
};