Fix a bunch of linter errors
diff --git a/src/commands/help.ts b/src/commands/help.ts
index 900f24c..921318e 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -10,10 +10,13 @@
interaction.reply("hel p"); // TODO: FINISH THIS FOR RELEASE
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index c2a76a9..7bdd813 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -1,4 +1,4 @@
const name = "mod";
const description = "Perform moderator actions";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index a55dcfa..4560c8b 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,8 +15,20 @@
builder
.setName("ban")
.setDescription("Bans a user from the server")
- .addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
- .addNumberOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to ban")
+ .setRequired(true)
+ )
+ .addNumberOption((option) =>
+ option
+ .setName("delete")
+ .setDescription("The days of messages to delete | Default: 0")
+ .setMinValue(0)
+ .setMaxValue(7)
+ .setRequired(false)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
@@ -23,13 +40,25 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n`
- + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
- + `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n` +
+ `${addPlurals(
+ interaction.options.getInteger("delete")
+ ? interaction.options.getInteger("delete")
+ : 0,
+ "day"
+ )} of messages will be deleted\n\n` +
+ `Are you sure you want to ban <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -37,7 +66,8 @@
if (confirmation.cancelled) return;
if (confirmation.success) break;
if (confirmation.newReason) reason = confirmation.newReason;
- if (confirmation.components) notify = confirmation.components.notify.active;
+ if (confirmation.components)
+ notify = confirmation.components.notify.active;
}
if (confirmation.success) {
let dmd = false;
@@ -45,31 +75,52 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Banned")
- .setDescription(`You have been banned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Banned")
+ .setDescription(
+ `You have been banned in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.ban.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- const member = (interaction.options.getMember("user") as GuildMember);
+ const member = interaction.options.getMember("user") as GuildMember;
member.ban({
days: Number(interaction.options.getNumber("delete") ?? 0),
reason: reason ?? "No reason provided"
});
- await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ await client.database.history.create(
+ "ban",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberBan",
@@ -82,10 +133,22 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
- reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ banned: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ bannedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ reason: entry(
+ reason,
+ reason ? `\n> ${reason}` : "*No reason provided.*"
+ ),
+ accountCreated: entry(
+ member.user.createdAt,
+ renderDelta(member.user.createdAt)
+ ),
serverMemberCount: interaction.guild.memberCount
},
hidden: {
@@ -94,56 +157,79 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Ban")
- .setDescription("Something went wrong and the user was not banned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Ban")
+ .setDescription(
+ "Something went wrong and the user was not banned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Ban")
- .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Ban")
+ .setDescription(
+ "The member was banned" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Ban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.GREEN")
+ .setTitle("Ban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow banning the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot ban the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot ban the owner of the server";
// Check if Nucleus can ban the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to ban
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Do not allow banning Nucleus
if (member.id === interaction.guild.me.id) throw "I cannot ban myself";
// Allow the owner to ban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow ban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 68b3ce7..86a4c4a 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,5 +1,11 @@
import { HistorySchema } from "../../utils/database";
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ TextInputComponent
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -11,51 +17,88 @@
builder
.setName("info")
.setDescription("Shows moderator information about a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to get information about")
+ .setRequired(true)
+ );
const types = {
- "warn": {emoji: "PUNISH.WARN.YELLOW", text: "Warned"},
- "mute": {emoji: "PUNISH.MUTE.YELLOW", text: "Muted"},
- "unmute": {emoji: "PUNISH.MUTE.GREEN", text: "Unmuted"},
- "join": {emoji: "MEMBER.JOIN", text: "Joined"},
- "leave": {emoji: "MEMBER.LEAVE", text: "Left"},
- "kick": {emoji: "MEMBER.KICK", text: "Kicked"},
- "softban": {emoji: "PUNISH.SOFTBAN", text: "Softbanned"},
- "ban": {emoji: "MEMBER.BAN", text: "Banned"},
- "unban": {emoji: "MEMBER.UNBAN", text: "Unbanned"},
- "purge": {emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared"},
- "nickname": {emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed"}
+ warn: { emoji: "PUNISH.WARN.YELLOW", text: "Warned" },
+ mute: { emoji: "PUNISH.MUTE.YELLOW", text: "Muted" },
+ unmute: { emoji: "PUNISH.MUTE.GREEN", text: "Unmuted" },
+ join: { emoji: "MEMBER.JOIN", text: "Joined" },
+ leave: { emoji: "MEMBER.LEAVE", text: "Left" },
+ kick: { emoji: "MEMBER.KICK", text: "Kicked" },
+ softban: { emoji: "PUNISH.SOFTBAN", text: "Softbanned" },
+ ban: { emoji: "MEMBER.BAN", text: "Banned" },
+ unban: { emoji: "MEMBER.UNBAN", text: "Unbanned" },
+ purge: { emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared" },
+ nickname: { emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed" }
};
function historyToString(history: HistorySchema) {
let s = `${getEmojiByName(types[history.type].emoji)} ${
- history.amount ? (history.amount + " ") : ""
- }${
- types[history.type].text
- } on <t:${Math.round(history.occurredAt.getTime() / 1000)}:F>`;
- if (history.moderator) { s += ` by <@${history.moderator}>`; }
- if (history.reason) { s += `\n**Reason:**\n> ${history.reason}`; }
- if (history.before) { s += `\n**Before:**\n> ${history.before}`; }
- if (history.after) { s += `\n**After:**\n> ${history.after}`; }
+ history.amount ? history.amount + " " : ""
+ }${types[history.type].text} on <t:${Math.round(
+ history.occurredAt.getTime() / 1000
+ )}:F>`;
+ if (history.moderator) {
+ s += ` by <@${history.moderator}>`;
+ }
+ if (history.reason) {
+ s += `\n**Reason:**\n> ${history.reason}`;
+ }
+ if (history.before) {
+ s += `\n**Before:**\n> ${history.before}`;
+ }
+ if (history.after) {
+ s += `\n**After:**\n> ${history.after}`;
+ }
return s + "\n";
}
-
class TimelineSection {
name: string;
- content: {data: HistorySchema, rendered: string}[] = [];
+ content: { data: HistorySchema; rendered: string }[] = [];
- addContent = (content: {data: HistorySchema, rendered: string}) => { this.content.push(content); return this; };
- contentLength = () => { return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0); };
+ addContent = (content: { data: HistorySchema; rendered: string }) => {
+ this.content.push(content);
+ return this;
+ };
+ contentLength = () => {
+ return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0);
+ };
generateName = () => {
- const first = Math.round(this.content[0].data.occurredAt.getTime() / 1000);
- const last = Math.round(this.content[this.content.length - 1].data.occurredAt.getTime() / 1000);
- if (first === last) { return this.name = `<t:${first}:F>`; }
- return this.name = `<t:${first}:F> - <t:${last}:F>`;
+ const first = Math.round(
+ this.content[0].data.occurredAt.getTime() / 1000
+ );
+ const last = Math.round(
+ this.content[this.content.length - 1].data.occurredAt.getTime() /
+ 1000
+ );
+ if (first === last) {
+ return (this.name = `<t:${first}:F>`);
+ }
+ return (this.name = `<t:${first}:F> - <t:${last}:F>`);
};
}
-const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+const monthNames = [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+];
async function showHistory(member, interaction: CommandInteraction) {
let currentYear = new Date().getFullYear();
@@ -66,41 +109,72 @@
let openFilterPane = false;
while (true) {
if (refresh) {
- history = await client.database.history.read(member.guild.id, member.id, currentYear);
- history = history.sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime()).reverse();
+ history = await client.database.history.read(
+ member.guild.id,
+ member.id,
+ currentYear
+ );
+ history = history
+ .sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime())
+ .reverse();
if (openFilterPane) {
let tempFilteredTypes = filteredTypes;
- if (filteredTypes.length === 0) { tempFilteredTypes = Object.keys(types); }
- history = history.filter(h => tempFilteredTypes.includes(h.type));
+ if (filteredTypes.length === 0) {
+ tempFilteredTypes = Object.keys(types);
+ }
+ history = history.filter((h) =>
+ tempFilteredTypes.includes(h.type)
+ );
}
refresh = false;
}
const groups: TimelineSection[] = [];
if (history.length > 0) {
current = new TimelineSection();
- history.forEach(event => {
- if (current.contentLength() + historyToString(event).length > 2000 || current.content.length === 5) {
+ history.forEach((event) => {
+ if (
+ current.contentLength() + historyToString(event).length >
+ 2000 ||
+ current.content.length === 5
+ ) {
groups.push(current);
current.generateName();
current = new TimelineSection();
}
- current.addContent({data: event, rendered: historyToString(event)});
+ current.addContent({
+ data: event,
+ rendered: historyToString(event)
+ });
});
current.generateName();
groups.push(current);
- if (pageIndex === null) { pageIndex = groups.length - 1; }
+ if (pageIndex === null) {
+ pageIndex = groups.length - 1;
+ }
}
const components = (
- openFilterPane ? [
- new MessageActionRow().addComponents([new Discord.MessageSelectMenu().setOptions(
- Object.entries(types).map(([key, value]) => ({
- label: value.text,
- value: key,
- default: filteredTypes.includes(key),
- emoji: client.emojis.resolve(getEmojiByName(value.emoji, "id"))
- }))
- ).setMinValues(1).setMaxValues(Object.keys(types).length).setCustomId("filter").setPlaceholder("Select at least one event")])
- ] : []).concat([
+ openFilterPane
+ ? [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .setOptions(
+ Object.entries(types).map(([key, value]) => ({
+ label: value.text,
+ value: key,
+ default: filteredTypes.includes(key),
+ emoji: client.emojis.resolve(
+ getEmojiByName(value.emoji, "id")
+ )
+ }))
+ )
+ .setMinValues(1)
+ .setMaxValues(Object.keys(types).length)
+ .setCustomId("filter")
+ .setPlaceholder("Select at least one event")
+ ])
+ ]
+ : []
+ ).concat([
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("prevYear")
@@ -119,14 +193,18 @@
.setCustomId("nextPage")
.setLabel("Next page")
.setStyle("PRIMARY")
- .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ .setDisabled(
+ pageIndex >= groups.length - 1 &&
+ currentYear === new Date().getFullYear()
+ ),
new MessageButton()
.setCustomId("nextYear")
.setLabel((currentYear + 1).toString())
.setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
.setStyle("SECONDARY")
.setDisabled(currentYear === new Date().getFullYear())
- ]), new MessageActionRow().addComponents([
+ ]),
+ new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Mod notes")
.setCustomId("modNotes")
@@ -139,40 +217,82 @@
.setEmoji(getEmojiByName("ICONS.FILTER", "id"))
])
]);
- const end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
- Math.max(groups.length, 1),
- groups.length === 0 ? 1 : pageIndex
- ) + (currentYear === new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
- ) + " " + currentYear.toString();
+ const end =
+ "\n\nJanuary " +
+ currentYear.toString() +
+ pageIndicator(
+ Math.max(groups.length, 1),
+ groups.length === 0 ? 1 : pageIndex
+ ) +
+ (currentYear === new Date().getFullYear()
+ ? monthNames[new Date().getMonth()]
+ : "December") +
+ " " +
+ currentYear.toString();
if (groups.length > 0) {
const toRender = groups[Math.min(pageIndex, groups.length - 1)];
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(`**${toRender.name}**\n\n` + toRender.content.map(c => c.rendered).join("\n") + end)
- .setStatus("Success")
- .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
- ], components: components});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(
+ `**${toRender.name}**\n\n` +
+ toRender.content
+ .map((c) => c.rendered)
+ .join("\n") +
+ end
+ )
+ .setStatus("Success")
+ .setFooter({
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : ""
+ })
+ ],
+ components: components
+ });
} else {
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(`**${currentYear}**\n\n*No events*` + "\n\n" + end)
- .setStatus("Success")
- .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
- ], components: components});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(
+ `**${currentYear}**\n\n*No events*` + "\n\n" + end
+ )
+ .setStatus("Success")
+ .setFooter({
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : ""
+ })
+ ],
+ components: components
+ });
}
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(m.embeds[0].description)
- .setStatus("Danger")
- .setFooter({text: "Message timed out"})
- ]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(m.embeds[0].description)
+ .setStatus("Danger")
+ .setFooter({ text: "Message timed out" })
+ ]
+ });
return 0;
}
i.deferUpdate();
@@ -181,103 +301,170 @@
pageIndex = null;
refresh = true;
}
- if (i.customId === "prevYear") { currentYear--; pageIndex = null; refresh = true; }
- if (i.customId === "nextYear") { currentYear++; pageIndex = null; refresh = true; }
+ if (i.customId === "prevYear") {
+ currentYear--;
+ pageIndex = null;
+ refresh = true;
+ }
+ if (i.customId === "nextYear") {
+ currentYear++;
+ pageIndex = null;
+ refresh = true;
+ }
if (i.customId === "prevPage") {
pageIndex--;
- if (pageIndex < 0) { pageIndex = null; currentYear--; refresh = true; }
+ if (pageIndex < 0) {
+ pageIndex = null;
+ currentYear--;
+ refresh = true;
+ }
}
if (i.customId === "nextPage") {
pageIndex++;
- if (pageIndex >= groups.length) { pageIndex = 0; currentYear++; refresh = true; }
+ if (pageIndex >= groups.length) {
+ pageIndex = 0;
+ currentYear++;
+ refresh = true;
+ }
}
- if (i.customId === "today") { currentYear = new Date().getFullYear(); pageIndex = null; refresh = true; }
- if (i.customId === "modNotes") { return 1; }
- if (i.customId === "openFilter") { openFilterPane = !openFilterPane; refresh = true; }
+ if (i.customId === "today") {
+ currentYear = new Date().getFullYear();
+ pageIndex = null;
+ refresh = true;
+ }
+ if (i.customId === "modNotes") {
+ return 1;
+ }
+ if (i.customId === "openFilter") {
+ openFilterPane = !openFilterPane;
+ refresh = true;
+ }
}
}
-
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
let m;
- const member = (interaction.options.getMember("user")) as Discord.GuildMember;
- await interaction.reply({embeds: [new EmojiEmbed()
- .setEmoji("NUCLEUS.LOADING")
- .setTitle("Downloading Data")
- .setStatus("Danger")
- ], ephemeral: true, fetchReply: true});
+ const member = interaction.options.getMember("user") as Discord.GuildMember;
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("NUCLEUS.LOADING")
+ .setTitle("Downloading Data")
+ .setStatus("Danger")
+ ],
+ ephemeral: true,
+ fetchReply: true
+ });
let note;
let firstLoad = true;
while (true) {
note = await client.database.notes.read(member.guild.id, member.id);
- if (firstLoad && !note) { await showHistory(member, interaction); }
+ if (firstLoad && !note) {
+ await showHistory(member, interaction);
+ }
firstLoad = false;
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Mod notes for " + member.user.username)
- .setDescription(note ? note : "*No note set*")
- .setStatus("Success")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel(`${note ? "Modify" : "Create"} note`)
- .setStyle("PRIMARY")
- .setCustomId("modify")
- .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
- new MessageButton()
- .setLabel("View moderation history")
- .setStyle("PRIMARY")
- .setCustomId("history")
- .setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
- ])]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Mod notes for " + member.user.username)
+ .setDescription(note ? note : "*No note set*")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(`${note ? "Modify" : "Create"} note`)
+ .setStyle("PRIMARY")
+ .setCustomId("modify")
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new MessageButton()
+ .setLabel("View moderation history")
+ .setStyle("PRIMARY")
+ .setCustomId("history")
+ .setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return; }
+ } catch (e) {
+ return;
+ }
if (i.customId === "modify") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Editing moderator note").addComponents(
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("note")
- .setLabel("Note")
- .setMaxLength(4000)
- .setRequired(false)
- .setStyle("PARAGRAPH")
- .setValue(note ? note : "")
- )
- ));
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle("Editing moderator note")
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("note")
+ .setLabel("Note")
+ .setMaxLength(4000)
+ .setRequired(false)
+ .setStyle("PARAGRAPH")
+ .setValue(note ? note : "")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Mod notes for " + member.user.username)
- .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("Mod notes for " + member.user.username)
+ .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) { continue; }
+ out = await modalInteractionCollector(
+ m,
+ (m) => m.channel.id === interaction.channel.id,
+ (m) => m.customId === "modify"
+ );
+ } catch (e) {
+ continue;
+ }
if (out.fields) {
const toAdd = out.fields.getTextInputValue("note") || null;
- await client.database.notes.create(member.guild.id, member.id, toAdd);
- } else { continue; }
+ await client.database.notes.create(
+ member.guild.id,
+ member.id,
+ toAdd
+ );
+ } else {
+ continue;
+ }
} else if (i.customId === "history") {
i.deferUpdate();
- if (!await showHistory(member, interaction) ) return;
+ if (!(await showHistory(member, interaction))) return;
}
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ const member = interaction.member as GuildMember;
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 23785c3..59c2f81 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import humanizeDuration from "humanize-duration";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -10,9 +15,16 @@
builder
.setName("kick")
.setDescription("Kicks a user from the server")
- .addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to kick")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -22,12 +34,19 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kick")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to kick <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -45,28 +64,51 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.RED")
- .setTitle("Kicked")
- .setDescription(`You have been kicked in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.RED")
+ .setTitle("Kicked")
+ .setDescription(
+ `You have been kicked in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.kick.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.kick.text)
- .setURL(config.moderation.kick.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.kick.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.kick.text)
+ .setURL(config.moderation.kick.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- (interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.");
- const member = (interaction.options.getMember("user") as GuildMember);
- await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ (interaction.options.getMember("user") as GuildMember).kick(
+ reason ?? "No reason provided."
+ );
+ const member = interaction.options.getMember("user") as GuildMember;
+ await client.database.history.create(
+ "kick",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberKick",
@@ -79,12 +121,35 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- kickedBy: entry(interaction.user.id, renderUser(interaction.user)),
- reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
- timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedTimestamp, { round: true })),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ joined: entry(
+ member.joinedAt,
+ renderDelta(member.joinedAt)
+ ),
+ kicked: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ kickedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ reason: entry(
+ reason,
+ reason ? `\n> ${reason}` : "*No reason provided.*"
+ ),
+ timeInServer: entry(
+ new Date().getTime() - member.joinedTimestamp,
+ humanizeDuration(
+ new Date().getTime() - member.joinedTimestamp,
+ {
+ round: true
+ }
+ )
+ ),
+ accountCreated: entry(
+ member.user.createdAt,
+ renderDelta(member.user.createdAt)
+ ),
serverMemberCount: member.guild.memberCount
},
hidden: {
@@ -93,56 +158,79 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.RED")
- .setTitle("Kick")
- .setDescription("Something went wrong and the user was not kicked")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.RED")
+ .setTitle("Kick")
+ .setDescription(
+ "Something went wrong and the user was not kicked"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Kick")
- .setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Kick")
+ .setDescription(
+ "The member was kicked" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.GREEN")
- .setTitle("Kick")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.GREEN")
+ .setTitle("Kick")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow kicking the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot kick the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot kick the owner of the server";
// Check if Nucleus can kick the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to kick
- if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the *Kick Members* permission";
+ if (!me.permissions.has("KICK_MEMBERS"))
+ throw "I do not have the *Kick Members* permission";
// Do not allow kicking Nucleus
if (member.id === interaction.guild.me.id) throw "I cannot kick myself";
// Allow the owner to kick anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has kick_members permission
- if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the *Kick Members* permission";
+ if (!member.permissions.has("KICK_MEMBERS"))
+ throw "You do not have the *Kick Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow kick
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 1e9a812..5be6f43 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,5 +1,11 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -7,20 +13,69 @@
import keyValueList from "../../utils/generateKeyValueList.js";
import humanizeDuration from "humanize-duration";
import client from "../../utils/client.js";
-import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
+import {
+ areTicketsEnabled,
+ create
+} from "../../actions/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("mute")
- .setDescription("Mutes a member, stopping them from talking in the server")
- .addUserOption(option => option.setName("user").setDescription("The user to mute").setRequired(true))
- .addIntegerOption(option => option.setName("days").setDescription("The number of days to mute the user for | Default: 0").setMinValue(0).setMaxValue(27).setRequired(false))
- .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false))
- .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
- .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false));
+ .setDescription(
+ "Mutes a member, stopping them from talking in the server"
+ )
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to mute")
+ .setRequired(true)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("days")
+ .setDescription(
+ "The number of days to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(27)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("hours")
+ .setDescription(
+ "The number of hours to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(23)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("minutes")
+ .setDescription(
+ "The number of minutes to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(59)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("seconds")
+ .setDescription(
+ "The number of seconds to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(59)
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const { log, NucleusColors, renderUser, entry, renderDelta } =
+ client.logger;
const user = interaction.options.getMember("user") as GuildMember;
const time = {
days: interaction.options.getInteger("days") || 0,
@@ -29,85 +84,136 @@
seconds: interaction.options.getInteger("seconds") || 0
};
const config = await client.database.guilds.read(interaction.guild.id);
- let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "");
- if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`;
+ let serverSettingsDescription = config.moderation.mute.timeout
+ ? "given a timeout"
+ : "";
+ if (config.moderation.mute.role)
+ serverSettingsDescription +=
+ (serverSettingsDescription ? " and " : "") +
+ `given the <@&${config.moderation.mute.role}> role`;
- let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds;
+ let muteTime =
+ time.days * 24 * 60 * 60 +
+ time.hours * 60 * 60 +
+ time.minutes * 60 +
+ time.seconds;
if (muteTime === 0) {
- const m = await interaction.reply({embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Mute")
- .setDescription("How long should the user be muted")
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("1m")
- .setLabel("1 Minute")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("10m")
- .setLabel("10 Minutes")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("30m")
- .setLabel("30 Minutes")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1h")
- .setLabel("1 Hour")
- .setStyle("SECONDARY")
- ]),
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("6h")
- .setLabel("6 Hours")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("12h")
- .setLabel("12 Hours")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1d")
- .setLabel("1 Day")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1w")
- .setLabel("1 Week")
- .setStyle("SECONDARY")
- ]),
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("cancel")
- .setLabel("Cancel")
- .setStyle("DANGER")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])
- ], ephemeral: true, fetchReply: true}) as Message;
+ const m = (await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Mute")
+ .setDescription("How long should the user be muted")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("1m")
+ .setLabel("1 Minute")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("10m")
+ .setLabel("10 Minutes")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("30m")
+ .setLabel("30 Minutes")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1h")
+ .setLabel("1 Hour")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("6h")
+ .setLabel("6 Hours")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("12h")
+ .setLabel("12 Hours")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1d")
+ .setLabel("1 Day")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1w")
+ .setLabel("1 Week")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("cancel")
+ .setLabel("Cancel")
+ .setStyle("DANGER")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])
+ ],
+ ephemeral: true,
+ fetchReply: true
+ })) as Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
component.deferUpdate();
- if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Mute")
- .setDescription("Mute cancelled")
- .setStatus("Danger")
- ]});
+ if (component.customId === "cancel")
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Mute")
+ .setDescription("Mute cancelled")
+ .setStatus("Danger")
+ ]
+ });
switch (component.customId) {
- case "1m": { muteTime = 60; break; }
- case "10m": { muteTime = 60 * 10; break; }
- case "30m": { muteTime = 60 * 30; break; }
- case "1h": { muteTime = 60 * 60; break; }
- case "6h": { muteTime = 60 * 60 * 6; break; }
- case "12h": { muteTime = 60 * 60 * 12; break; }
- case "1d": { muteTime = 60 * 60 * 24; break; }
- case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
+ case "1m": {
+ muteTime = 60;
+ break;
+ }
+ case "10m": {
+ muteTime = 60 * 10;
+ break;
+ }
+ case "30m": {
+ muteTime = 60 * 30;
+ break;
+ }
+ case "1h": {
+ muteTime = 60 * 60;
+ break;
+ }
+ case "6h": {
+ muteTime = 60 * 60 * 6;
+ break;
+ }
+ case "12h": {
+ muteTime = 60 * 60 * 12;
+ break;
+ }
+ case "1d": {
+ muteTime = 60 * 60 * 24;
+ break;
+ }
+ case "1w": {
+ muteTime = 60 * 60 * 24 * 7;
+ break;
+ }
}
} else {
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ });
}
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -118,20 +224,47 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
- .setDescription(keyValueList({
- "user": renderUser(user.user),
- "time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + "The user will be " + serverSettingsDescription + "\n"
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to mute <@!${user.id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(user.user),
+ time: `${humanizeDuration(muteTime * 1000, {
+ round: true
+ })}`,
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ "The user will be " +
+ serverSettingsDescription +
+ "\n" +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to mute <@!${user.id}>?`
+ )
.setColor("Danger")
.addCustomBoolean(
- "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ "appeal",
+ "Create appeal ticket",
+ !(await areTicketsEnabled(interaction.guild.id)),
+ async () =>
+ await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason
+ ),
+ "An appeal ticket will be created when Confirm is clicked",
+ "CONTROL.TICKET",
+ createAppealTicket
+ )
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(true);
reason = reason ?? "";
@@ -150,69 +283,135 @@
try {
if (notify) {
dm = await user.send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Muted")
- .setDescription(`You have been muted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".\n\n" +
- `You will be unmuted at: <t:${Math.round((new Date).getTime() / 1000) + muteTime}:D> at <t:${Math.round((new Date).getTime() / 1000) + muteTime}:T> (<t:${Math.round((new Date).getTime() / 1000) + muteTime}:R>)`) +
- (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Muted")
+ .setDescription(
+ `You have been muted in ${interaction.guild.name}` +
+ (reason
+ ? ` for:\n> ${reason}`
+ : ".\n\n" +
+ `You will be unmuted at: <t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:D> at <t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:T> (<t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:R>)`) +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.mute.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.mute.text)
- .setURL(config.moderation.mute.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.mute.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.mute.text)
+ .setURL(config.moderation.mute.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
const member = user;
let errors = 0;
try {
if (config.moderation.mute.timeout) {
- await member.timeout(muteTime * 1000, reason || "No reason provided");
+ await member.timeout(
+ muteTime * 1000,
+ reason || "No reason provided"
+ );
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild.id,
- user: user.id,
- expires: new Date().getTime() + muteTime * 1000
- });
+ await client.database.eventScheduler.schedule(
+ "naturalUnmute",
+ new Date().getTime() + muteTime * 1000,
+ {
+ guild: interaction.guild.id,
+ user: user.id,
+ expires: new Date().getTime() + muteTime * 1000
+ }
+ );
}
}
- } catch { errors++; }
+ } catch {
+ errors++;
+ }
try {
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild.id,
- user: user.id,
- role: config.moderation.mute.role
- });
+ await client.database.eventScheduler.schedule(
+ "unmuteRole",
+ new Date().getTime() + muteTime * 1000,
+ {
+ guild: interaction.guild.id,
+ user: user.id,
+ role: config.moderation.mute.role
+ }
+ );
}
- } catch (e){ console.log(e); errors++; }
+ } catch (e) {
+ console.log(e);
+ errors++;
+ }
if (errors === 2) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Mute")
- .setDescription("Something went wrong and the user was not muted")
- .setStatus("Danger")
- ], components: []}); // TODO: make this clearer
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Mute")
+ .setDescription(
+ "Something went wrong and the user was not muted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ }); // TODO: make this clearer
if (dmd) await dm.delete();
return;
}
- await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Mute")
- .setDescription("The member was muted" + (failed ? ", but could not be notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ await client.database.history.create(
+ "mute",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Mute")
+ .setDescription(
+ "The member was muted" +
+ (failed ? ", but could not be notified" : "") +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
const data = {
- meta:{
+ meta: {
type: "memberMute",
displayName: "Member Muted",
calculateType: "guildMemberPunish",
@@ -223,9 +422,18 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- mutedUntil: entry(new Date().getTime() + muteTime * 1000, renderDelta(new Date().getTime() + muteTime * 1000)),
- muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
- mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ mutedUntil: entry(
+ new Date().getTime() + muteTime * 1000,
+ renderDelta(new Date().getTime() + muteTime * 1000)
+ ),
+ muted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime() - 1000)
+ ),
+ mutedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
reason: entry(reason, reason ? reason : "*No reason provided*")
},
hidden: {
@@ -234,39 +442,49 @@
};
log(data);
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Mute")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Mute")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow muting the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot mute the owner of the server";
// Check if Nucleus can mute the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to mute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
+ if (!me.permissions.has("MODERATE_MEMBERS"))
+ throw "I do not have the *Moderate Members* permission";
// Do not allow muting Nucleus
if (member.id === me.id) throw "I cannot mute myself";
// Allow the owner to mute anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow mute
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 06fab47..c3d6b33 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -9,10 +9,22 @@
builder
.setName("nick")
.setDescription("Changes a users nickname")
- .addUserOption(option => option.setName("user").setDescription("The user to change").setRequired(true))
- .addStringOption(option => option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to change")
+ .setRequired(true)
+ )
+ .addStringOption((option) =>
+ option
+ .setName("name")
+ .setDescription("The name to set | Leave blank to clear")
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let notify = true;
@@ -21,14 +33,35 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ "new nickname": `${
+ interaction.options.getString("name")
+ ? interaction.options.getString("name")
+ : "*No nickname*"
+ }`
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to ${
+ interaction.options.getString("name")
+ ? "change"
+ : "clear"
+ } <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>'s nickname?`
+ )
.setColor("Danger")
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.send(interaction.options.getString("name") !== null);
if (confirmation.cancelled) return;
if (confirmation.success) break;
@@ -41,28 +74,53 @@
let dm;
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.RED")
- .setTitle("Nickname changed")
- .setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
- (interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : "") + "\n\n" +
- (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname changed")
+ .setDescription(
+ `Your nickname was ${
+ interaction.options.getString("name")
+ ? "changed"
+ : "cleared"
+ } in ${interaction.guild.name}.` +
+ (interaction.options.getString("name")
+ ? ` it is now: ${interaction.options.getString(
+ "name"
+ )}`
+ : "") +
+ "\n\n" +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- const member = (interaction.options.getMember("user") as GuildMember);
+ const member = interaction.options.getMember("user") as GuildMember;
const before = member.nickname;
const nickname = interaction.options.getString("name");
member.setNickname(nickname ?? null, "Nucleus Nickname command");
await client.database.history.create(
- "nickname", interaction.guild.id, member.user, interaction.user,
- null, before, nickname);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ "nickname",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ null,
+ before,
+ nickname
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberUpdate",
@@ -76,8 +134,14 @@
memberId: entry(member.id, `\`${member.id}\``),
before: entry(before, before ? before : "*None*"),
after: entry(nickname, nickname ? nickname : "*None*"),
- updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- updatedBy: entry(interaction.user.id, renderUser(interaction.user))
+ updated: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ updatedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ )
},
hidden: {
guild: interaction.guild.id
@@ -85,56 +149,82 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.RED")
- .setTitle("Nickname")
- .setDescription("Something went wrong and the users nickname could not be changed.")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname")
+ .setDescription(
+ "Something went wrong and the users nickname could not be changed."
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Nickname")
- .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Nickname")
+ .setDescription(
+ "The members nickname was changed" +
+ (failed ? ", but was not notified" : "") +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setTitle("Nickname")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setTitle("Nickname")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow any changing of the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot change the owner's nickname";
// Check if Nucleus can change the nickname
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to change the nickname
- if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the *Manage Nicknames* permission";
+ if (!me.permissions.has("MANAGE_NICKNAMES"))
+ throw "I do not have the *Manage Nicknames* permission";
// Allow the owner to change anyone's nickname
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_nicknames permission
- if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the *Manage Nicknames* permission";
+ if (!member.permissions.has("MANAGE_NICKNAMES"))
+ throw "You do not have the *Manage Nicknames* permission";
// Allow changing your own nickname
if (member === apply) return true;
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow change
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index c554ee7..b78c423 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,9 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildChannel,
+ GuildMember,
+ TextChannel
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,19 +15,41 @@
builder
.setName("purge")
.setDescription("Bulk deletes messages in a channel")
- .addIntegerOption(option => option
- .setName("amount")
- .setDescription("The amount of messages to delete")
- .setRequired(false)
- .setMinValue(1)
- .setMaxValue(100))
- .addUserOption(option => option.setName("user").setDescription("The user to purge messages from").setRequired(false))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the purge").setRequired(false));
+ .addIntegerOption((option) =>
+ option
+ .setName("amount")
+ .setDescription("The amount of messages to delete")
+ .setRequired(false)
+ .setMinValue(1)
+ .setMaxValue(100)
+ )
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to purge messages from")
+ .setRequired(false)
+ )
+ .addStringOption((option) =>
+ option
+ .setName("reason")
+ .setDescription("The reason for the purge")
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const user = interaction.options.getMember("user") as GuildMember ?? null;
- const channel = (interaction.channel as GuildChannel);
- if (!(["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(channel.type.toString()))) {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const user = (interaction.options.getMember("user") as GuildMember) ?? null;
+ const channel = interaction.channel as GuildChannel;
+ if (
+ ![
+ "GUILD_TEXT",
+ "GUILD_NEWS",
+ "GUILD_NEWS_THREAD",
+ "GUILD_PUBLIC_THREAD",
+ "GUILD_PRIVATE_THREAD"
+ ].includes(channel.type.toString())
+ ) {
return await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -36,7 +63,7 @@
});
}
// TODO:[Modals] Replace this with a modal
- if ( !interaction.options.getInteger("amount") ) {
+ if (!interaction.options.getInteger("amount")) {
await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -51,12 +78,14 @@
});
let deleted = [] as Discord.Message[];
while (true) {
- const m = await interaction.editReply({
+ const m = (await interaction.editReply({
embeds: [
new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
- .setDescription("Select how many messages to delete. You can continue clicking until all messages are cleared.")
+ .setDescription(
+ "Select how many messages to delete. You can continue clicking until all messages are cleared."
+ )
.setStatus("Danger")
],
components: [
@@ -96,40 +125,64 @@
.setEmoji(getEmojiByName("CONTROL.TICK", "id"))
])
]
- }) as Discord.Message;
+ })) as Discord.Message;
let component;
try {
- component = m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch (e) { break; }
+ component = m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch (e) {
+ break;
+ }
component.deferUpdate();
if (component.customId === "done") break;
let amount;
- try { amount = parseInt(component.customId); } catch { break; }
+ try {
+ amount = parseInt(component.customId);
+ } catch {
+ break;
+ }
let messages;
- await (interaction.channel as TextChannel).messages.fetch({limit: amount}).then(async (ms) => {
- if (user) {
- ms = ms.filter(m => m.author.id === user.id);
- }
- messages = await (channel as TextChannel).bulkDelete(ms, true);
- });
+ await (interaction.channel as TextChannel).messages
+ .fetch({ limit: amount })
+ .then(async (ms) => {
+ if (user) {
+ ms = ms.filter((m) => m.author.id === user.id);
+ }
+ messages = await (channel as TextChannel).bulkDelete(
+ ms,
+ true
+ );
+ });
if (messages) {
- deleted = deleted.concat(messages.map(m => m));
+ deleted = deleted.concat(messages.map((m) => m));
}
}
- if (deleted.length === 0) return await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.RED")
- .setTitle("Purge")
- .setDescription("No messages were deleted")
- .setStatus("Danger")
- ],
- components: []
- });
+ if (deleted.length === 0)
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.RED")
+ .setTitle("Purge")
+ .setDescription("No messages were deleted")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (user) {
- await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, deleted.length);
+ await client.database.history.create(
+ "purge",
+ interaction.guild.id,
+ user,
+ interaction.options.getString("reason"),
+ null,
+ null,
+ deleted.length
+ );
}
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -140,9 +193,18 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ purgedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ channel: entry(
+ interaction.channel.id,
+ renderChannel(interaction.channel)
+ ),
messagesCleared: entry(deleted.length, deleted.length)
},
hidden: {
@@ -151,10 +213,16 @@
};
log(data);
let out = "";
- deleted.reverse().forEach(message => {
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+ deleted.reverse().forEach((message) => {
+ out += `${message.author.username}#${
+ message.author.discriminator
+ } (${message.author.id}) [${new Date(
+ message.createdTimestamp
+ ).toISOString()}]\n`;
const lines = message.content.split("\n");
- lines.forEach(line => {out += `> ${line}\n`;});
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
out += "\n\n";
});
const attachmentObject = {
@@ -162,47 +230,73 @@
name: `purge-${channel.id}-${Date.now()}.txt`,
description: "Purge log"
};
- const m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: [new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("download")
- .setLabel("Download transcript")
- .setStyle("SUCCESS")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ])]}) as Discord.Message;
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: [
+ new Discord.MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("download")
+ .setLabel("Download transcript")
+ .setStyle("SUCCESS")
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+ ])
+ ]
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Uploaded")
- .setStatus("Success")
- ], components: [], files: [attachmentObject]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Uploaded")
+ .setStatus("Success")
+ ],
+ components: [],
+ files: [attachmentObject]
+ });
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: []});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
return;
} else {
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
- .setDescription(keyValueList({
- "channel": `<#${channel.id}>`,
- "amount": interaction.options.getInteger("amount").toString(),
- "reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
- }))
+ .setDescription(
+ keyValueList({
+ channel: `<#${channel.id}>`,
+ amount: interaction.options.getInteger("amount").toString(),
+ reason: `\n> ${
+ interaction.options.getString("reason")
+ ? interaction.options.getString("reason")
+ : "*No reason provided*"
+ }`
+ })
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
@@ -210,25 +304,57 @@
let messages;
try {
if (!user) {
- const toDelete = await (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")});
- messages = await (channel as TextChannel).bulkDelete(toDelete, true);
+ const toDelete = await (
+ interaction.channel as TextChannel
+ ).messages.fetch({
+ limit: interaction.options.getInteger("amount")
+ });
+ messages = await (channel as TextChannel).bulkDelete(
+ toDelete,
+ true
+ );
} else {
- const toDelete = (await (await (interaction.channel as TextChannel).messages.fetch({limit: 100}))
- .filter(m => m.author.id === user.id)).first(interaction.options.getInteger("amount"));
- messages = await (channel as TextChannel).bulkDelete(toDelete, true);
+ const toDelete = (
+ await (
+ await (
+ interaction.channel as TextChannel
+ ).messages.fetch({
+ limit: 100
+ })
+ ).filter((m) => m.author.id === user.id)
+ ).first(interaction.options.getInteger("amount"));
+ messages = await (channel as TextChannel).bulkDelete(
+ toDelete,
+ true
+ );
}
- } catch(e) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.RED")
- .setTitle("Purge")
- .setDescription("Something went wrong and no messages were deleted")
- .setStatus("Danger")
- ], components: []});
+ } catch (e) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.RED")
+ .setTitle("Purge")
+ .setDescription(
+ "Something went wrong and no messages were deleted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
if (user) {
- await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, messages.size);
+ await client.database.history.create(
+ "purge",
+ interaction.guild.id,
+ user,
+ interaction.options.getString("reason"),
+ null,
+ null,
+ messages.size
+ );
}
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -239,9 +365,18 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ purgedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ channel: entry(
+ interaction.channel.id,
+ renderChannel(interaction.channel)
+ ),
messagesCleared: entry(messages.size, messages.size)
},
hidden: {
@@ -250,10 +385,16 @@
};
log(data);
let out = "";
- messages.reverse().forEach(message => {
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+ messages.reverse().forEach((message) => {
+ out += `${message.author.username}#${
+ message.author.discriminator
+ } (${message.author.id}) [${new Date(
+ message.createdTimestamp
+ ).toISOString()}]\n`;
const lines = message.content.split("\n");
- lines.forEach(line => {out += `> ${line}\n`;});
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
out += "\n\n";
});
const attachmentObject = {
@@ -261,59 +402,85 @@
name: `purge-${channel.id}-${Date.now()}.txt`,
description: "Purge log"
};
- const m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: [new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("download")
- .setLabel("Download transcript")
- .setStyle("SUCCESS")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ])]}) as Discord.Message;
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: [
+ new Discord.MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("download")
+ .setLabel("Download transcript")
+ .setStyle("SUCCESS")
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+ ])
+ ]
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Transcript uploaded above")
- .setStatus("Success")
- ], components: [], files: [attachmentObject]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Transcript uploaded above")
+ .setStatus("Success")
+ ],
+ components: [],
+ files: [attachmentObject]
+ });
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: []});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
// Check if nucleus has the manage_messages permission
- if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
+ if (!me.permissions.has("MANAGE_MESSAGES"))
+ throw "I do not have the *Manage Messages* permission";
// Allow the owner to purge
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_messages permission
- if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the *Manage Messages* permission";
+ if (!member.permissions.has("MANAGE_MESSAGES"))
+ throw "You do not have the *Manage Messages* permission";
// Allow purge
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 7e8b8a2..1a06db1 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -5,29 +5,51 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("slowmode")
.setDescription("Manages slowmode in a channel")
- .addStringOption(option => option.setName("time").setDescription("The delay between messages").setRequired(false).addChoices([
- ["Off", "0"],
- ["5 seconds", "5"], ["10 seconds", "10"], ["15 seconds", "15"], ["30 seconds", "30"],
- ["1 minute", "60"], ["2 minutes", "120"], ["5 minutes", "300"], ["10 minutes", "600"],
- ["15 minutes", "900"], ["30 minutes", "1800"],
- ["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
- ]));
+ .addStringOption((option) =>
+ option
+ .setName("time")
+ .setDescription("The delay between messages")
+ .setRequired(false)
+ .addChoices([
+ ["Off", "0"],
+ ["5 seconds", "5"],
+ ["10 seconds", "10"],
+ ["15 seconds", "15"],
+ ["30 seconds", "30"],
+ ["1 minute", "60"],
+ ["2 minutes", "120"],
+ ["5 minutes", "300"],
+ ["10 minutes", "600"],
+ ["15 minutes", "900"],
+ ["30 minutes", "1800"],
+ ["1 hour", "3600"],
+ ["2 hours", "7200"],
+ ["6 hours", "21600"]
+ ])
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
let time = parseInt(interaction.options.getString("time") ?? "0");
- if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10; }
+ if (
+ time === 0 &&
+ (interaction.channel as TextChannel).rateLimitPerUser === 0
+ ) {
+ time = 10;
+ }
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setTitle("Slowmode")
- .setDescription(keyValueList({
- "time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay"
- })
- + "Are you sure you want to set the slowmode in this channel?")
+ .setDescription(
+ keyValueList({
+ time: time
+ ? humanizeDuration(time * 1000, { round: true })
+ : "No delay"
+ }) + "Are you sure you want to set the slowmode in this channel?"
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
@@ -35,37 +57,53 @@
try {
(interaction.channel as TextChannel).setRateLimitPerUser(time);
} catch (e) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.OFF")
- .setTitle("Slowmode")
- .setDescription("Something went wrong while setting the slowmode")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
+ .setTitle("Slowmode")
+ .setDescription(
+ "Something went wrong while setting the slowmode"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.ON")
- .setTitle("Slowmode")
- .setDescription("The channel slowmode was set successfully")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.ON")
+ .setTitle("Slowmode")
+ .setDescription("The channel slowmode was set successfully")
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.ON")
- .setTitle("Slowmode")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.ON")
+ .setTitle("Slowmode")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
+ const member = interaction.member as GuildMember;
// Check if Nucleus can set the slowmode
- if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the *Manage Channels* permission";
+ if (!interaction.guild.me.permissions.has("MANAGE_CHANNELS"))
+ throw "I do not have the *Manage Channels* permission";
// Check if the user has manage_channel permission
- if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the *Manage Channels* permission";
+ if (!member.permissions.has("MANAGE_CHANNELS"))
+ throw "You do not have the *Manage Channels* permission";
// Allow slowmode
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index d0dc9bb..f3c475e 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,10 +15,24 @@
builder
.setName("softban")
.setDescription("Kicks a user and deletes their messages")
- .addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
- .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to softban")
+ .setRequired(true)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("delete")
+ .setDescription("The days of messages to delete | Default: 0")
+ .setMinValue(0)
+ .setMaxValue(7)
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,15 +42,35 @@
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n`
- + `${addPlural(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
- + `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n` +
+ `${addPlural(
+ interaction.options.getInteger("delete")
+ ? interaction.options.getInteger("delete")
+ : 0,
+ "day"
+ )} of messages will be deleted\n\n` +
+ `Are you sure you want to softban <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -47,24 +86,38 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softbanned")
- .setDescription(`You have been softbanned from ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softbanned")
+ .setDescription(
+ `You have been softbanned from ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.ban.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false;}
- const member = (interaction.options.getMember("user") as GuildMember);
+ } catch {
+ dmd = false;
+ }
+ const member = interaction.options.getMember("user") as GuildMember;
try {
await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
@@ -72,55 +125,83 @@
});
await interaction.guild.members.unban(member, "Softban");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softban")
- .setDescription("Something went wrong and the user was not softbanned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softban")
+ .setDescription(
+ "Something went wrong and the user was not softbanned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await client.database.history.create("softban", interaction.guild.id, member.user, reason);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Softban")
- .setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ await client.database.history.create(
+ "softban",
+ interaction.guild.id,
+ member.user,
+ reason
+ );
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Softban")
+ .setDescription(
+ "The member was softbanned" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Softban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.GREEN")
+ .setTitle("Softban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow softbanning the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot softban the owner of the server";
// Check if Nucleus can ban the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Do not allow softbanning Nucleus
if (member.id === me.id) throw "I cannot softban myself";
// Allow the owner to softban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow softban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 88301eb..06fe647 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -9,39 +9,68 @@
builder
.setName("unban")
.setDescription("Unbans a user")
- .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true));
+ .addStringOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to unban (Username or ID)")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const bans = await interaction.guild.bans.fetch();
const user = interaction.options.getString("user");
- let resolved = bans.find(ban => ban.user.id === user);
- if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() === user.toLowerCase());
- if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() === user.toLowerCase());
+ let resolved = bans.find((ban) => ban.user.id === user);
+ if (!resolved)
+ resolved = bans.find(
+ (ban) => ban.user.username.toLowerCase() === user.toLowerCase()
+ );
+ if (!resolved)
+ resolved = bans.find(
+ (ban) => ban.user.tag.toLowerCase() === user.toLowerCase()
+ );
if (!resolved) {
- return interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Unban")
- .setDescription(`Could not find any user called \`${user}\``)
- .setEmoji("PUNISH.UNBAN.RED")
- .setStatus("Danger")
- ], ephemeral: true});
+ return interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Unban")
+ .setDescription(
+ `Could not find any user called \`${user}\``
+ )
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setStatus("Danger")
+ ],
+ ephemeral: true
+ });
}
// TODO:[Modals] Replace this with a modal
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.UNBAN.RED")
.setTitle("Unban")
- .setDescription(keyValueList({
- "user": `${resolved.user.username} [<@${resolved.user.id}>]`
- })
- + `Are you sure you want to unban <@${resolved.user.id}>?`)
+ .setDescription(
+ keyValueList({
+ user: `${resolved.user.username} [<@${resolved.user.id}>]`
+ }) + `Are you sure you want to unban <@${resolved.user.id}>?`
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await interaction.guild.members.unban(resolved.user as User, "Unban");
- const member = (resolved.user as User);
- await client.database.history.create("unban", interaction.guild.id, member, interaction.user);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ await interaction.guild.members.unban(
+ resolved.user as User,
+ "Unban"
+ );
+ const member = resolved.user as User;
+ await client.database.history.create(
+ "unban",
+ interaction.guild.id,
+ member,
+ interaction.user
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberUnban",
@@ -54,9 +83,18 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member)),
- unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unbannedBy: entry(interaction.user.id, renderUser(interaction.user)),
- accountCreated: entry(member.createdAt, renderDelta(member.createdAt))
+ unbanned: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ unbannedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ accountCreated: entry(
+ member.createdAt,
+ renderDelta(member.createdAt)
+ )
},
hidden: {
guild: interaction.guild.id
@@ -64,40 +102,56 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.RED")
- .setTitle("Unban")
- .setDescription("Something went wrong and the user was not unbanned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setTitle("Unban")
+ .setDescription(
+ "Something went wrong and the user was not unbanned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.GREEN")
- .setTitle("Unban")
- .setDescription("The member was unbanned")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.GREEN")
+ .setTitle("Unban")
+ .setDescription("The member was unbanned")
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.GREEN")
- .setTitle("Unban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.GREEN")
+ .setTitle("Unban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
// Check if Nucleus can unban members
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Allow the owner to unban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Allow unban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index d4e0d75..f625461 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -9,24 +9,37 @@
builder
.setName("unmute")
.setDescription("Unmutes a user")
- .addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to unmute")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const { log, NucleusColors, renderUser, entry, renderDelta } =
+ client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
let notify = false;
let confirmation;
while (true) {
- confirmation = await new confirmationMessage(interaction)
+ confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Unmute")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": `\n> ${reason ? reason : "*No reason provided*"}`
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: `\n> ${reason ? reason : "*No reason provided*"}`
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to unmute <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -42,32 +55,53 @@
let dm;
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmuted")
- .setDescription(`You have been unmuted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : " with no reason provided."))
- .setStatus("Success")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Unmuted")
+ .setDescription(
+ `You have been unmuted in ${interaction.guild.name}` +
+ (reason
+ ? ` for:\n> ${reason}`
+ : " with no reason provided.")
+ )
+ .setStatus("Success")
]
});
dmd = true;
}
- } catch { dmd = false; }
- const member = (interaction.options.getMember("user") as GuildMember);
+ } catch {
+ dmd = false;
+ }
+ const member = interaction.options.getMember("user") as GuildMember;
try {
member.timeout(0, reason || "No reason provided");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Unmute")
- .setDescription("Something went wrong and the user was not unmuted")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Unmute")
+ .setDescription(
+ "Something went wrong and the user was not unmuted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, reason);
+ await client.database.history.create(
+ "unmute",
+ interaction.guild.id,
+ (interaction.options.getMember("user") as GuildMember).user,
+ interaction.user,
+ reason
+ );
const data = {
meta: {
type: "memberUnmute",
@@ -80,53 +114,76 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
+ unmuted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ unmutedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ )
},
hidden: {
guild: interaction.guild.id
}
};
log(data);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Unmute")
- .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Unmute")
+ .setDescription(
+ "The member was unmuted" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmute")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Unmute")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow unmuting the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot unmute the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot unmute the owner of the server";
// Check if Nucleus can unmute the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to unmute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
+ if (!me.permissions.has("MODERATE_MEMBERS"))
+ throw "I do not have the *Moderate Members* permission";
// Allow the owner to unmute anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow unmute
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ca52787..f0b2047 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,11 @@
-import Discord, { CategoryChannel, CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+ CategoryChannel,
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ MessageSelectMenu
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -8,97 +15,189 @@
builder
.setName("viewas")
.setDescription("View the server as a specific member")
- .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("member")
+ .setDescription("The member to view as")
+ .setRequired(true)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
let channels = [];
let m;
- interaction.guild.channels.cache.forEach(channel => {
- if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel);
+ interaction.guild.channels.cache.forEach((channel) => {
+ if (!channel.parent && channel.type !== "GUILD_CATEGORY")
+ channels.push(channel);
});
channels = [channels];
- channels = channels.concat(interaction.guild.channels.cache
- .filter(c => c.type === "GUILD_CATEGORY")
- .map(c => (c as CategoryChannel).children.map(c => c))
+ channels = channels.concat(
+ interaction.guild.channels.cache
+ .filter((c) => c.type === "GUILD_CATEGORY")
+ .map((c) => (c as CategoryChannel).children.map((c) => c))
);
const autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"];
- channels = channels.map(c => c.sort((a, b) => {
- if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position;
- if (autoSortBelow.includes(a.type)) return 1;
- if (autoSortBelow.includes(b.type)) return -1;
- return a.position - b.position;
- }));
+ channels = channels.map((c) =>
+ c.sort((a, b) => {
+ if (
+ autoSortBelow.includes(a.type) &&
+ autoSortBelow.includes(b.type)
+ )
+ return a.position - b.position;
+ if (autoSortBelow.includes(a.type)) return 1;
+ if (autoSortBelow.includes(b.type)) return -1;
+ return a.position - b.position;
+ })
+ );
// Sort all arrays by the position of the first channels parent position
channels = channels.sort((a, b) => {
if (!a[0].parent) return -1;
if (!b[0].parent) return 1;
return a[0].parent.position - b[0].parent.position;
});
- const member = interaction.options.getMember("member") as Discord.GuildMember;
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- ], ephemeral: true, fetchReply: true});
+ const member = interaction.options.getMember(
+ "member"
+ ) as Discord.GuildMember;
+ m = await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ ],
+ ephemeral: true,
+ fetchReply: true
+ });
let page = 0;
while (true) {
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- .setDescription(
- `**${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}**` + "\n" +
- channels[page].map(c => {
- let channelType = c.type;
- if (interaction.guild.rulesChannelId === c.id) channelType = "RULES";
- else if ("nsfw" in c && c.nsfw) channelType += "_NSFW";
- return c.permissionsFor(member).has("VIEW_CHANNEL") ? (
- `${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` + (() => {
- if ("threads" in c && c.threads.cache.size > 0) {
- return c.threads.cache.map(t => ` ${
- getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") + " " +
- getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")} ${t.name}`).join("\n") + "\n";
- }return "";
- })()) : "";
- }).join("") + "\n" + pageIndicator(channels.length, page)
- )
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(channels.map((c, index) => ({
- label: c[0].parent ? c[0].parent.name : "Uncategorised",
- value: index.toString(),
- default: page === index
- }))).setCustomId("select").setMaxValues(1).setMinValues(1).setPlaceholder("Select a category")]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel(page === 0 ? "" : (channels[page - 1][0].parent ? channels[page - 1][0].parent.name : "Uncategorised"))
- .setDisabled(page === 0)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("previous"),
- new MessageButton()
- .setLabel(page === channels.length - 1 ? "" : (channels[page + 1][0].parent ? channels[page + 1][0].parent.name : "Uncategorised"))
- .setDisabled(page === channels.length - 1)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("next")
- ])
- ]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ .setDescription(
+ `**${
+ channels[page][0].parent
+ ? channels[page][0].parent.name
+ : "Uncategorised"
+ }**` +
+ "\n" +
+ channels[page]
+ .map((c) => {
+ let channelType = c.type;
+ if (
+ interaction.guild.rulesChannelId ===
+ c.id
+ )
+ channelType = "RULES";
+ else if ("nsfw" in c && c.nsfw)
+ channelType += "_NSFW";
+ return c
+ .permissionsFor(member)
+ .has("VIEW_CHANNEL")
+ ? `${getEmojiByName(
+ "ICONS.CHANNEL." + channelType
+ )} ${c.name}\n` +
+ (() => {
+ if (
+ "threads" in c &&
+ c.threads.cache.size > 0
+ ) {
+ return (
+ c.threads.cache
+ .map(
+ (t) =>
+ ` ${
+ getEmojiByName(
+ "ICONS.CHANNEL.THREAD_PIPE"
+ ) +
+ " " +
+ getEmojiByName(
+ "ICONS.CHANNEL.THREAD_CHANNEL"
+ )
+ } ${
+ t.name
+ }`
+ )
+ .join("\n") + "\n"
+ );
+ }
+ return "";
+ })()
+ : "";
+ })
+ .join("") +
+ "\n" +
+ pageIndicator(channels.length, page)
+ )
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setOptions(
+ channels.map((c, index) => ({
+ label: c[0].parent
+ ? c[0].parent.name
+ : "Uncategorised",
+ value: index.toString(),
+ default: page === index
+ }))
+ )
+ .setCustomId("select")
+ .setMaxValues(1)
+ .setMinValues(1)
+ .setPlaceholder("Select a category")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(
+ page === 0
+ ? ""
+ : channels[page - 1][0].parent
+ ? channels[page - 1][0].parent.name
+ : "Uncategorised"
+ )
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("previous"),
+ new MessageButton()
+ .setLabel(
+ page === channels.length - 1
+ ? ""
+ : channels[page + 1][0].parent
+ ? channels[page + 1][0].parent.name
+ : "Uncategorised"
+ )
+ .setDisabled(page === channels.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("next")
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return; }
+ } catch (e) {
+ return;
+ }
i.deferUpdate();
- if (i.customId === "next") { page++; }
- else if (i.customId === "previous") { page--; }
- else if (i.customId === "select") { page = parseInt(i.values[0]); }
+ if (i.customId === "next") {
+ page++;
+ } else if (i.customId === "previous") {
+ page--;
+ } else if (i.customId === "select") {
+ page = parseInt(i.values[0]);
+ }
}
};
-
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
+ const member = interaction.member as GuildMember;
+ if (!member.permissions.has("MANAGE_ROLES"))
+ throw "You do not have the *Manage Roles* permission";
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 34ad3c3..91c876e 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,18 +1,33 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
+import {
+ create,
+ areTicketsEnabled
+} from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("warn")
.setDescription("Warns a user")
- .addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to warn")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { log, NucleusColors, renderUser, entry } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,18 +38,44 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to warn <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addCustomBoolean(
- "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ "appeal",
+ "Create appeal ticket",
+ !(await areTicketsEnabled(interaction.guild.id)),
+ async () =>
+ await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason
+ ),
+ "An appeal ticket will be created when Confirm is clicked",
+ "CONTROL.TICKET",
+ createAppealTicket
+ )
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -50,31 +91,51 @@
let dmd = false;
try {
if (notify) {
- const config = await client.database.guilds.read(interaction.guild.id);
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warned")
- .setDescription(`You have been warned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
- (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
- .setFooter({
- text: config.moderation.warn.text ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site." : "",
- iconURL: "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
- })
+ const config = await client.database.guilds.read(
+ interaction.guild.id
+ );
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warned")
+ .setDescription(
+ `You have been warned in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".") +
+ "\n\n" +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
+ .setFooter({
+ text: config.moderation.warn.text
+ ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site."
+ : "",
+ iconURL:
+ "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
+ })
],
- components: config.moderation.warn.text ? [new MessageActionRow().addComponents([new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link)
- ])] : []
+ components: config.moderation.warn.text
+ ? [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.warn.text)
+ .setURL(config.moderation.warn.link)
+ ])
+ ]
+ : []
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
const data = {
- meta:{
+ meta: {
type: "memberWarn",
displayName: "Member warned",
calculateType: "guildMemberPunish",
@@ -83,8 +144,18 @@
timestamp: new Date().getTime()
},
list: {
- user: entry((interaction.options.getMember("user") as GuildMember).user.id, renderUser((interaction.options.getMember("user") as GuildMember).user)),
- warnedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ user: entry(
+ (interaction.options.getMember("user") as GuildMember).user
+ .id,
+ renderUser(
+ (interaction.options.getMember("user") as GuildMember)
+ .user
+ )
+ ),
+ warnedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
reason: reason ? `\n> ${reason}` : "No reason provided"
},
hidden: {
@@ -92,28 +163,47 @@
}
};
await client.database.history.create(
- "warn", interaction.guild.id,
+ "warn",
+ interaction.guild.id,
(interaction.options.getMember("user") as GuildMember).user,
- interaction.user, reason
+ interaction.user,
+ reason
);
log(data);
- const failed = (dmd === false && notify);
+ const failed = !dmd && notify;
if (!failed) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- const canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL");
- const m = await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("The user's DMs are not open\n\nWhat would you like to do?")
- .setStatus("Danger")
- ], components: [
+ const canSeeChannel = (
+ interaction.options.getMember("user") as GuildMember
+ )
+ .permissionsIn(interaction.channel as Discord.TextChannel)
+ .has("VIEW_CHANNEL");
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "The user's DMs are not open\n\nWhat would you like to do?"
+ )
+ .setStatus("Danger")
+ ],
+ components: [
new MessageActionRow().addComponents([
new Discord.MessageButton()
.setCustomId("log")
@@ -130,76 +220,131 @@
.setStyle(canSeeChannel ? "SECONDARY" : "PRIMARY")
])
]
- }) as Discord.Message;
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ if (component.customId === "here") {
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "You have been warned" +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
+ ],
+ content: `<@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>`,
+ allowedMentions: {
+ users: [
+ (
+ interaction.options.getMember(
+ "user"
+ ) as GuildMember
+ ).id
+ ]
+ }
+ });
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.response
+ ? ` and an appeal ticket was opened in <#${confirmation.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "log") {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("The warn was logged")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "ticket") {
+ const ticketChannel = await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason,
+ "Warn Notification"
+ );
+ if (ticketChannel === null) {
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription("A ticket could not be created")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ }
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ `A ticket was created in <#${ticketChannel}>`
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ }
+ } else {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle("Warn")
.setDescription("No changes were made")
.setStatus("Success")
- ], components: []});
- }
- if ( component.customId === "here" ) {
- await interaction.channel.send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("You have been warned" +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
- ],
- content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
- allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
- });
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ""))
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "log") {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The warn was logged")
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "ticket") {
- const ticketChannel = await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason, "Warn Notification");
- if (ticketChannel === null) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("A ticket could not be created")
- .setStatus("Danger")
- ], components: []});
- }
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription(`A ticket was created in <#${ticketChannel}>`)
- .setStatus("Success")
- ], components: []});
- }
- }
- } else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow warning bots
@@ -207,11 +352,13 @@
// Allow the owner to warn anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow warn
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/nucleus/_meta.ts b/src/commands/nucleus/_meta.ts
index df978ba..a79a596 100644
--- a/src/commands/nucleus/_meta.ts
+++ b/src/commands/nucleus/_meta.ts
@@ -1,4 +1,4 @@
const name = "nucleus";
const description = "Commands relating to Nucleus itself";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index 3141f9f..b9df446 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -6,7 +6,6 @@
.setName("guide")
.setDescription("Shows the welcome guide for the bot");
-
const callback = async (interaction) => {
guide(interaction.guild, interaction);
};
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index ebc3c34..8ae8c1a 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -1,24 +1,38 @@
-import { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("invite")
- .setDescription("Invites Nucleus to your server");
+ builder.setName("invite").setDescription("Invites Nucleus to your server");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Invite")
- .setDescription("You can invite Nucleus to your server by clicking the button below")
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Invite")
- .setStyle("LINK")
- .setURL(`https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=295157886134&scope=bot%20applications.commands`)
- ])], ephemeral: true});
+ interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Invite")
+ .setDescription(
+ "You can invite Nucleus to your server by clicking the button below"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Invite")
+ .setStyle("LINK")
+ .setURL(
+ `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=295157886134&scope=bot%20applications.commands`
+ )
+ ])
+ ],
+ ephemeral: true
+ });
};
const check = () => {
@@ -27,4 +41,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 91e8363..105cda5 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -5,26 +5,29 @@
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("ping")
- .setDescription("Gets the bot's ping time");
+ builder.setName("ping").setDescription("Gets the bot's ping time");
const callback = async (interaction: CommandInteraction): Promise<void> => {
// WEBSOCKET | Nucleus -> Discord
// EDITING | Nucleus -> discord -> nucleus | edit time / 2
const initial = new Date().getTime();
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+ await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
const ping = new Date().getTime() - initial;
- interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Ping")
- .setDescription(
- `**Ping:** \`${ping}ms\`\n` +
- `**To Discord:** \`${client.ws.ping}ms\`\n` +
- `**From Expected:** \`±${Math.abs((ping / 2) - client.ws.ping)}ms\``
- )
- .setEmoji("CHANNEL.SLOWMODE.OFF")
- .setStatus("Danger")
- ]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Ping")
+ .setDescription(
+ `**Ping:** \`${ping}ms\`\n` +
+ `**To Discord:** \`${client.ws.ping}ms\`\n` +
+ `**From Expected:** \`±${Math.abs(
+ ping / 2 - client.ws.ping
+ )}ms\``
+ )
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
+ .setStatus("Danger")
+ ]
+ });
};
const check = () => {
@@ -33,4 +36,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 9ad2c16..83ba327 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -8,17 +8,21 @@
.setDescription("Information about Nucleus Premium");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Premium")
- .setDescription(
- "*Nucleus Premium is currently not available.*\n\n" +
- "Premium allows your server to get access to extra features, for a fixed price per month.\nThis includes:\n" +
- "- Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n" +
- "- Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n"
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ], ephemeral: true});
+ interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Premium")
+ .setDescription(
+ "*Nucleus Premium is currently not available.*\n\n" +
+ "Premium allows your server to get access to extra features, for a fixed price per month.\nThis includes:\n" +
+ "- Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n" +
+ "- Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ ],
+ ephemeral: true
+ });
};
const check = () => {
@@ -27,4 +31,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index 2558997..68eeaa9 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -4,22 +4,21 @@
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("stats")
- .setDescription("Gets the bot's stats");
+ builder.setName("stats").setDescription("Gets the bot's stats");
const callback = async (interaction: CommandInteraction): Promise<void> => {
interaction.reply({
- embeds: [new EmojiEmbed()
- .setTitle("Stats")
- .setDescription(
- `**Servers:** ${client.guilds.cache.size}\n` +
- `**Ping:** \`${client.ws.ping*2}ms\``
- )
- .setStatus("Success")
- .setEmoji("GUILD.GRAPHS")
-
- ], ephemeral: true
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Stats")
+ .setDescription(
+ `**Servers:** ${client.guilds.cache.size}\n` +
+ `**Ping:** \`${client.ws.ping * 2}ms\``
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.GRAPHS")
+ ],
+ ephemeral: true
});
};
@@ -29,4 +28,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index a6657d8..0f40501 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -9,7 +9,12 @@
builder
.setName("suggest")
.setDescription("Sends a suggestion to the developers")
- .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true));
+ .addStringOption((option) =>
+ option
+ .setName("suggestion")
+ .setDescription("The suggestion to send")
+ .setRequired(true)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
@@ -17,42 +22,63 @@
const confirmation = await new confirmationMessage(interaction)
.setEmoji("ICONS.OPP.ADD")
.setTitle("Suggest")
- .setDescription(`**Suggestion:**\n> ${suggestion}\n`
- + "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?")
+ .setDescription(
+ `**Suggestion:**\n> ${suggestion}\n` +
+ "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
+ )
.setColor("Danger")
.setInverted(true)
.send();
if (confirmation.cancelled) return;
if (confirmation.success) {
- await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
+ await (
+ client.channels.cache.get(
+ "955161206459600976"
+ ) as Discord.TextChannel
+ ).send({
embeds: [
new EmojiEmbed()
.setTitle("Suggestion")
- .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
+ .setDescription(
+ `**From:** ${renderUser(
+ interaction.member.user
+ )}\n**Suggestion:**\n> ${suggestion}`
+ )
.setStatus("Danger")
.setEmoji("NUCLEUS.LOGO")
]
});
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("ICONS.ADD")
- .setTitle("Suggest")
- .setDescription("Your suggestion was sent successfully")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("ICONS.ADD")
+ .setTitle("Suggest")
+ .setDescription("Your suggestion was sent successfully")
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("ICONS.OPP.ADD")
- .setTitle("Suggest")
- .setDescription("No changes were made")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("ICONS.OPP.ADD")
+ .setTitle("Suggest")
+ .setDescription("No changes were made")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 8fb6b40..3c36ea1 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,5 +1,9 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -10,7 +14,9 @@
const command = new SlashCommandBuilder()
.setName("privacy")
- .setDescription("Information and options for you and your server's settings");
+ .setDescription(
+ "Information and options for you and your server's settings"
+ );
class Embed {
embed: Discord.MessageEmbed;
@@ -18,61 +24,111 @@
description = "";
pageId = 0;
components?: MessageActionRow[] = [];
- setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
- setTitle(title: string) { this.title = title; return this; }
- setDescription(description: string) { this.description = description; return this; }
- setPageId(pageId: number) { this.pageId = pageId; return this; }
- setComponents(components: MessageActionRow[]) { this.components = components; return this; }
+ setEmbed(embed: Discord.MessageEmbed) {
+ this.embed = embed;
+ return this;
+ }
+ setTitle(title: string) {
+ this.title = title;
+ return this;
+ }
+ setDescription(description: string) {
+ this.description = description;
+ return this;
+ }
+ setPageId(pageId: number) {
+ this.pageId = pageId;
+ return this;
+ }
+ setComponents(components: MessageActionRow[]) {
+ this.components = components;
+ return this;
+ }
}
const callback = async (interaction: CommandInteraction): Promise<void> => {
const pages = [
new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("Nucleus Privacy")
- .setDescription(
- "Nucleus is a bot that naturally needs to store data about servers.\n" +
- "We are entirely [open source](https://github.com/ClicksMinutePer/Nucleus), so you can check exactly what we store, and how it works.\n\n" +
- "If you are a server administrator, you can view the options page in the dropdown under this message.\n\n" +
- "Any questions about Nucleus, how it works and data stored can be asked in [our server](https://discord.gg/bPaNnxe)."
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ).setTitle("Welcome").setDescription("General privacy information").setPageId(0),
- new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("Scanners")
- .setDescription(
- "Nucleus uses [unscan](https://unscan.co) to scan links, images and files for malware and other threats.\n" +
- "This service's [privacy policy](https://unscan.co/policies) is public, and they \"do not store or sell your data.\""
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ).setTitle("Scanners").setDescription("About Unscan").setPageId(1),
- new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("Link scanning and Transcripts")
- .setDescription(
- "**Facebook** - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
- "**AMP** - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
- "Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ).setTitle("Link scanning and Transcripts").setDescription("Regarding Facebook and AMP filter types, and ticket transcripts").setPageId(2)
- ].concat((interaction.member as Discord.GuildMember).permissions.has("ADMINISTRATOR") ? [new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("Options")
- .setDescription(
- "Below are buttons for controlling this servers privacy settings"
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Nucleus Privacy")
+ .setDescription(
+ "Nucleus is a bot that naturally needs to store data about servers.\n" +
+ "We are entirely [open source](https://github.com/ClicksMinutePer/Nucleus), so you can check exactly what we store, and how it works.\n\n" +
+ "If you are a server administrator, you can view the options page in the dropdown under this message.\n\n" +
+ "Any questions about Nucleus, how it works and data stored can be asked in [our server](https://discord.gg/bPaNnxe)."
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
)
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger")
- ).setTitle("Options").setDescription("Options").setPageId(3).setComponents([new MessageActionRow().addComponents([
- new MessageButton().setLabel("Clear all data").setCustomId("clear-all-data").setStyle("DANGER")
- ])])
- ] : []);
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+ .setTitle("Welcome")
+ .setDescription("General privacy information")
+ .setPageId(0),
+ new Embed()
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Scanners")
+ .setDescription(
+ "Nucleus uses [unscan](https://unscan.co) to scan links, images and files for malware and other threats.\n" +
+ 'This service\'s [privacy policy](https://unscan.co/policies) is public, and they "do not store or sell your data."'
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ )
+ .setTitle("Scanners")
+ .setDescription("About Unscan")
+ .setPageId(1),
+ new Embed()
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Link scanning and Transcripts")
+ .setDescription(
+ "**Facebook** - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
+ "**AMP** - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
+ "Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ )
+ .setTitle("Link scanning and Transcripts")
+ .setDescription(
+ "Regarding Facebook and AMP filter types, and ticket transcripts"
+ )
+ .setPageId(2)
+ ].concat(
+ (interaction.member as Discord.GuildMember).permissions.has(
+ "ADMINISTRATOR"
+ )
+ ? [
+ new Embed()
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Options")
+ .setDescription(
+ "Below are buttons for controlling this servers privacy settings"
+ )
+ .setEmoji("NUCLEUS.LOGO")
+ .setStatus("Danger")
+ )
+ .setTitle("Options")
+ .setDescription("Options")
+ .setPageId(3)
+ .setComponents([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Clear all data")
+ .setCustomId("clear-all-data")
+ .setStyle("DANGER")
+ ])
+ ])
+ ]
+ : []
+ );
+ const m = await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ });
let page = 0;
let selectPaneOpen = false;
@@ -83,37 +139,59 @@
if (selectPaneOpen) {
const options = [];
- pages.forEach(embed => {
- options.push(new SelectMenuOption({
- label: embed.title,
- value: embed.pageId.toString(),
- description: embed.description || ""
- }));
+ pages.forEach((embed) => {
+ options.push(
+ new SelectMenuOption({
+ label: embed.title,
+ value: embed.pageId.toString(),
+ description: embed.description || ""
+ })
+ );
});
- selectPane = [new MessageActionRow().addComponents([
- new Discord.MessageSelectMenu()
- .addOptions(options)
- .setCustomId("page")
- .setMaxValues(1)
- .setPlaceholder("Choose a page...")
- ])];
+ selectPane = [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .addOptions(options)
+ .setCustomId("page")
+ .setMaxValues(1)
+ .setPlaceholder("Choose a page...")
+ ])
+ ];
}
- const components = selectPane.concat([new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
- new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
- ])]);
+ const components = selectPane.concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("left")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(page === 0),
+ new MessageButton()
+ .setCustomId("select")
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
+ .setDisabled(false),
+ new MessageButton()
+ .setCustomId("right")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(page === pages.length - 1)
+ ])
+ ]);
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
- em.setFooter({text: nextFooter ?? ""});
+ em.setDescription(
+ em.description + "\n\n" + createPageIndicator(pages.length, page)
+ );
+ em.setFooter({ text: nextFooter ?? "" });
await interaction.editReply({
embeds: [em],
components: components.concat(pages[page].components)
});
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ break;
+ }
nextFooter = null;
i.deferUpdate();
if (i.component.customId === "left") {
@@ -133,11 +211,13 @@
.setTitle("Clear All Data")
.setDescription(
"Are you sure you want to delete all data on this server? This includes your settings and all punishment histories.\n\n" +
- "**This cannot be undone.**"
+ "**This cannot be undone.**"
)
.setColor("Danger")
.send(true);
- if (confirmation.cancelled) { break; }
+ if (confirmation.cancelled) {
+ break;
+ }
if (confirmation.success) {
client.database.guilds.delete(interaction.guild.id);
client.database.history.delete(interaction.guild.id);
@@ -149,25 +229,34 @@
}
} else {
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
- em.setFooter({text: "Message closed"});
- interaction.editReply({embeds: [em], components: []});
+ em.setDescription(
+ em.description +
+ "\n\n" +
+ createPageIndicator(pages.length, page)
+ );
+ em.setFooter({ text: "Message closed" });
+ interaction.editReply({ embeds: [em], components: [] });
return;
}
}
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
- em.setFooter({text: "Message timed out"});
+ em.setDescription(
+ em.description + "\n\n" + createPageIndicator(pages.length, page)
+ );
+ em.setFooter({ text: "Message timed out" });
await interaction.editReply({
embeds: [em],
components: []
});
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/role/_meta.ts b/src/commands/role/_meta.ts
index 408576f..c5936c9 100644
--- a/src/commands/role/_meta.ts
+++ b/src/commands/role/_meta.ts
@@ -1,4 +1,4 @@
const name = "role";
const description = "Change roles for users";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index b54ee1e..2557b4b 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -10,25 +10,49 @@
builder
.setName("user")
.setDescription("Gives or removes a role from someone")
- .addUserOption(option => option.setName("user").setDescription("The member to give or remove the role from").setRequired(true))
- .addRoleOption(option => option.setName("role").setDescription("The role to give or remove").setRequired(true))
- .addStringOption(option => option.setName("action").setDescription("The action to perform").setRequired(true).addChoices([
- ["Add", "give"],
- ["Remove", "remove"]
- ]));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The member to give or remove the role from")
+ .setRequired(true)
+ )
+ .addRoleOption((option) =>
+ option
+ .setName("role")
+ .setDescription("The role to give or remove")
+ .setRequired(true)
+ )
+ .addStringOption((option) =>
+ option
+ .setName("action")
+ .setDescription("The action to perform")
+ .setRequired(true)
+ .addChoices([
+ ["Add", "give"],
+ ["Remove", "remove"]
+ ])
+ );
-
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser, renderRole } = client.logger;
const action = interaction.options.getString("action");
// TODO:[Modals] Replace this with a modal
const confirmation = await new confirmationMessage(interaction)
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Role")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "role": renderRole(interaction.options.getRole("role"))
- }) + `\nAre you sure you want to ${action === "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ role: renderRole(interaction.options.getRole("role"))
+ }) +
+ `\nAre you sure you want to ${
+ action === "give"
+ ? "give the role to"
+ : "remove the role from"
+ } ${interaction.options.getUser("user")}?`
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
@@ -42,44 +66,68 @@
member.roles.remove(role);
}
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Role")
- .setDescription("Something went wrong and the role could not be added")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription(
+ "Something went wrong and the role could not be added"
+ )
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ components: []
+ });
}
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Role")
- .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription(
+ `The role has been ${
+ action === "give" ? "given" : "removed"
+ } successfully`
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("GUILD.ROLES.CREATE")
- .setTitle("Role")
- .setDescription("No changes were made.")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setTitle("Role")
+ .setDescription("No changes were made.")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
// Check if Nucleus has permission to role
- if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
+ if (!me.permissions.has("MANAGE_ROLES"))
+ throw "I do not have the *Manage Roles* permission";
// Allow the owner to role anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_roles permission
- if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
+ if (!member.permissions.has("MANAGE_ROLES"))
+ throw "You do not have the *Manage Roles* permission";
// Allow role
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/rolemenu.ts b/src/commands/rolemenu.ts
index dd3cb34..8566966 100644
--- a/src/commands/rolemenu.ts
+++ b/src/commands/rolemenu.ts
@@ -11,7 +11,10 @@
await roleMenu(interaction);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
diff --git a/src/commands/server/_meta.ts b/src/commands/server/_meta.ts
index 379aac6..5c0ba48 100644
--- a/src/commands/server/_meta.ts
+++ b/src/commands/server/_meta.ts
@@ -1,4 +1,4 @@
const name = "server";
const description = "Commands for the server";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index c0a2ede..0a1cc6f 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -3,48 +3,84 @@
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
+import generateKeyValueList, {
+ toCapitals
+} from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
-const command = (builder: SlashCommandSubcommandBuilder) => builder
- .setName("about")
- .setDescription("Shows info about the server");
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder.setName("about").setDescription("Shows info about the server");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- const guild = interaction.guild as Guild;
+ const guild = interaction.guild!;
const { renderUser, renderDelta } = client.logger;
- interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Server Info")
- .setStatus("Success")
- .setEmoji("GUILD.GREEN")
- .setDescription(
- generateKeyValueList({
- "name": guild.name,
- "id": `\`${guild.id}\``,
- "owner": `${renderUser((await guild.fetchOwner()).user)}`,
- "created": `${renderDelta(guild.createdTimestamp)}`,
- "emojis": `${guild.emojis.cache.size}` + (guild.emojis.cache.size > 1 ? `\n> ${
- guild.emojis.cache.first(10).map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`).join(" ")
- }` +
- (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") : ""),
- "icon": `[Discord](${guild.iconURL()})`,
- "2 factor authentication": `${guild.mfaLevel === "NONE" ? `${getEmojiByName("CONTROL.CROSS")} No` : `${getEmojiByName("CONTROL.TICK")} Yes`}`,
- "verification level": `${toCapitals(guild.verificationLevel)}`,
- "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " " ))}`,
- "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
- "channels": `${guild.channels.cache.size}`,
- "roles": `${guild.roles.cache.size}`,
- "members": `${guild.memberCount}`
- })
- )
- .setThumbnail(guild.iconURL({dynamic: true}))
- ], ephemeral: true});
+ interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Server Info")
+ .setStatus("Success")
+ .setEmoji("GUILD.GREEN")
+ .setDescription(
+ generateKeyValueList({
+ name: guild.name,
+ id: `\`${guild.id}\``,
+ owner: `${renderUser((await guild.fetchOwner()).user)}`,
+ created: `${renderDelta(guild.createdTimestamp)}`,
+ emojis:
+ `${guild.emojis.cache.size}` +
+ (guild.emojis.cache.size > 1
+ ? `\n> ${guild.emojis.cache
+ .first(10)
+ .map(
+ (emoji) =>
+ `<${emoji.animated ? "a" : ""}:${
+ emoji.name
+ }:${emoji.id}>`
+ )
+ .join(" ")}` +
+ (guild.emojis.cache.size > 10
+ ? ` and ${
+ guild.emojis.cache.size - 10
+ } more`
+ : "")
+ : ""),
+ icon: `[Discord](${guild.iconURL()})`,
+ "2 factor authentication": `${
+ guild.mfaLevel === "NONE"
+ ? `${getEmojiByName("CONTROL.CROSS")} No`
+ : `${getEmojiByName("CONTROL.TICK")} Yes`
+ }`,
+ "verification level": `${toCapitals(
+ guild.verificationLevel
+ )}`,
+ "explicit content filter": `${toCapitals(
+ guild.explicitContentFilter
+ .toString()
+ .replace(/_/, " ")
+ )}`,
+ "nitro boost level": `${
+ guild.premiumTier !== "NONE"
+ ? guild.premiumTier.toString()[-1]
+ : "0"
+ }`,
+ channels: `${guild.channels.cache.size}`,
+ roles: `${guild.roles.cache.size}`,
+ members: `${guild.memberCount}`
+ })
+ )
+ .setThumbnail(guild.iconURL({ dynamic: true }))
+ ],
+ ephemeral: true
+ });
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
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;
};
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index adaf2cc..34c3152 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,4 +1,9 @@
-import { AutocompleteInteraction, CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import {
+ AutocompleteInteraction,
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import client from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -6,45 +11,68 @@
const command = new SlashCommandBuilder()
.setName("tag")
.setDescription("Get and manage the servers tags")
- .addStringOption(o => o.setName("tag").setDescription("The tag to get").setAutocomplete(true).setRequired(true));
+ .addStringOption((o) =>
+ o
+ .setName("tag")
+ .setDescription("The tag to get")
+ .setAutocomplete(true)
+ .setRequired(true)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const config = await client.database.guilds.read(interaction.guild.id);
const tags = config.getKey("tags");
const tag = tags[interaction.options.getString("tag")];
if (!tag) {
- return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag")
- .setDescription(`Tag \`${interaction.options.getString("tag")}\` does not exist`)
- .setEmoji("PUNISH.NICKNAME.RED")
- .setStatus("Danger")
- ], ephemeral: true});
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag")
+ .setDescription(
+ `Tag \`${interaction.options.getString(
+ "tag"
+ )}\` does not exist`
+ )
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setStatus("Danger")
+ ],
+ ephemeral: true
+ });
}
let url = "";
let components = [];
if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
url = tag;
- components = [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Open")
- .setURL(url)
- .setStyle("LINK")
- ])];
+ components = [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Open")
+ .setURL(url)
+ .setStyle("LINK")
+ ])
+ ];
}
- return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle(interaction.options.getString("tag"))
- .setDescription(tag)
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setStatus("Success")
- .setImage(url)
- ], components: components, ephemeral: true});
-
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(interaction.options.getString("tag"))
+ .setDescription(tag)
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setStatus("Success")
+ .setImage(url)
+ ],
+ components: components,
+ ephemeral: true
+ });
};
const check = () => {
return true;
};
-const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
+const autocomplete = async (
+ interaction: AutocompleteInteraction
+): Promise<string[]> => {
if (!interaction.guild) return [];
const config = await client.database.guilds.read(interaction.guild.id);
const tags = Object.keys(config.getKey("tags"));
diff --git a/src/commands/tags/_meta.ts b/src/commands/tags/_meta.ts
index 8c07682..2ce5318 100644
--- a/src/commands/tags/_meta.ts
+++ b/src/commands/tags/_meta.ts
@@ -1,4 +1,4 @@
const name = "tags";
const description = "manage server tags";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index 4aaa49d..5d6621b 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -9,76 +9,132 @@
builder
.setName("create")
.setDescription("Creates a tag")
- .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"))
- .addStringOption(o => o.setName("value").setRequired(true).setDescription("The value of the tag, shown after running /tag name"));
+ .addStringOption((o) =>
+ o
+ .setName("name")
+ .setRequired(true)
+ .setDescription("The name of the tag")
+ )
+ .addStringOption((o) =>
+ o
+ .setName("value")
+ .setRequired(true)
+ .setDescription(
+ "The value of the tag, shown after running /tag name"
+ )
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const name = interaction.options.getString("name");
const value = interaction.options.getString("value");
- if (name.length > 100) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("Tag names cannot be longer than 100 characters")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
- if (value.length > 1000) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("Tag values cannot be longer than 1000 characters")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
+ if (name.length > 100)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription(
+ "Tag names cannot be longer than 100 characters"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
+ if (value.length > 1000)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription(
+ "Tag values cannot be longer than 1000 characters"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
const data = await client.database.guilds.read(interaction.guild.id);
- if (data.tags.length >= 100) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("You cannot have more than 100 tags")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
- if (data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("That tag already exists")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
+ if (data.tags.length >= 100)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription("You cannot have more than 100 tags")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
+ if (data.tags[name])
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription("That tag already exists")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.YELLOW")
.setTitle("Tag create")
- .setDescription(keyValueList({
- "name": `${name}`,
- "value": `\n> ${value}`
- })
- + "\nAre you sure you want to create this tag?")
+ .setDescription(
+ keyValueList({
+ name: `${name}`,
+ value: `\n> ${value}`
+ }) + "\nAre you sure you want to create this tag?"
+ )
.setColor("Warning")
.setInverted(true)
.send();
if (confirmation.cancelled) return;
- if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ]});
+ if (!confirmation)
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ]
+ });
try {
- await client.database.guilds.write(interaction.guild.id, {[`tags.${name}`]: value});
+ await client.database.guilds.write(interaction.guild.id, {
+ [`tags.${name}`]: value
+ });
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("Something went wrong and the tag was not created")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription(
+ "Something went wrong and the tag was not created"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ components: []
+ });
}
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Create")
- .setDescription("Tag created")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Create")
+ .setDescription("Tag created")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ],
+ components: []
+ });
};
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;
};
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index 3509dcc..4d1a1aa 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -9,57 +9,87 @@
builder
.setName("delete")
.setDescription("Deletes a tag")
- .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"));
+ .addStringOption((o) =>
+ o
+ .setName("name")
+ .setRequired(true)
+ .setDescription("The name of the tag")
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const name = interaction.options.getString("name");
const data = await client.database.guilds.read(interaction.guild.id);
- if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tags")
- .setDescription("That tag does not exist")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
+ if (!data.tags[name])
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tags")
+ .setDescription("That tag does not exist")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.YELLOW")
.setTitle("Tag Delete")
- .setDescription(keyValueList({
- "name": `${name}`,
- "value": `\n> ${data.tags[name]}`
- })
- + "\nAre you sure you want to delete this tag?")
+ .setDescription(
+ keyValueList({
+ name: `${name}`,
+ value: `\n> ${data.tags[name]}`
+ }) + "\nAre you sure you want to delete this tag?"
+ )
.setColor("Warning")
.setInverted(true)
.send();
if (confirmation.cancelled) return;
- if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Delete")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ]});
+ if (!confirmation)
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Delete")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ]
+ });
try {
- await client.database.guilds.write(interaction.guild.id, null, ["tags." + name]);
+ await client.database.guilds.write(interaction.guild.id, null, [
+ "tags." + name
+ ]);
} catch (e) {
console.log(e);
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Delete")
- .setDescription("Something went wrong and the tag was not deleted")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Delete")
+ .setDescription(
+ "Something went wrong and the tag was not deleted"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ components: []
+ });
}
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Delete")
- .setDescription("Tag deleted")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Delete")
+ .setDescription("Tag deleted")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ],
+ components: []
+ });
};
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;
};
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index b9cdddf..192a2d4 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -9,63 +9,112 @@
builder
.setName("edit")
.setDescription("Edits or renames a tag")
- .addStringOption(o => o.setName("name").setRequired(true).setDescription("The tag to edit"))
- .addStringOption(o => o.setName("value").setRequired(false).setDescription("The new value of the tag / Rename"))
- .addStringOption(o => o.setName("newname").setRequired(false).setDescription("The new name of the tag / Edit"));
+ .addStringOption((o) =>
+ o
+ .setName("name")
+ .setRequired(true)
+ .setDescription("The tag to edit")
+ )
+ .addStringOption((o) =>
+ o
+ .setName("value")
+ .setRequired(false)
+ .setDescription("The new value of the tag / Rename")
+ )
+ .addStringOption((o) =>
+ o
+ .setName("newname")
+ .setRequired(false)
+ .setDescription("The new name of the tag / Edit")
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const name = interaction.options.getString("name");
const value = interaction.options.getString("value") || "";
const newname = interaction.options.getString("newname") || "";
- if (!newname && !value) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("You must specify a value or a new name")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
- if (newname.length > 100) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("Tag names cannot be longer than 100 characters")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
- if (value.length > 2000) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("Tag values cannot be longer than 2000 characters")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
+ if (!newname && !value)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription("You must specify a value or a new name")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
+ if (newname.length > 100)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription(
+ "Tag names cannot be longer than 100 characters"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
+ if (value.length > 2000)
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription(
+ "Tag values cannot be longer than 2000 characters"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
const data = await client.database.guilds.read(interaction.guild.id);
- if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("That tag does not exist")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
- if (newname && newname !== name && data.tags[newname]) return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("A tag with that name already exists")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], ephemeral: true});
+ if (!data.tags[name])
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription("That tag does not exist")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
+ if (newname && newname !== name && data.tags[newname])
+ return await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription("A tag with that name already exists")
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ ephemeral: true
+ });
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.YELLOW")
.setTitle("Tag Edit")
- .setDescription(keyValueList({
- "name": `${name}` + (newname ? ` -> ${newname}` : ""),
- "value": `\n> ${value ? value : data.tags[name]}`
- })
- + "\nAre you sure you want to edit this tag?")
+ .setDescription(
+ keyValueList({
+ name: `${name}` + (newname ? ` -> ${newname}` : ""),
+ value: `\n> ${value ? value : data.tags[name]}`
+ }) + "\nAre you sure you want to edit this tag?"
+ )
.setColor("Warning")
.setInverted(true)
.send();
if (confirmation.cancelled) return;
- if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ]});
+ if (!confirmation)
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ]
+ });
try {
const toSet = {};
const toUnset = [];
@@ -74,26 +123,41 @@
toUnset.push(`tags.${name}`);
toSet[`tags.${newname}`] = data.tags[name];
}
- await client.database.guilds.write(interaction.guild.id, toSet === {} ? null : toSet, toUnset);
+ await client.database.guilds.write(
+ interaction.guild.id,
+ toSet === {} ? null : toSet,
+ toUnset
+ );
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tag Edit")
- .setDescription("Something went wrong and the tag was not edited")
- .setStatus("Danger")
- .setEmoji("PUNISH.NICKNAME.RED")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tag Edit")
+ .setDescription(
+ "Something went wrong and the tag was not edited"
+ )
+ .setStatus("Danger")
+ .setEmoji("PUNISH.NICKNAME.RED")
+ ],
+ components: []
+ });
}
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Tags")
- .setDescription("Tag edited successfully")
- .setStatus("Success")
- .setEmoji("PUNISH.NICKNAME.GREEN")
- ], components: []});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Tags")
+ .setDescription("Tag edited successfully")
+ .setStatus("Success")
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ ],
+ components: []
+ });
};
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;
};
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index 1a6c22c..070aa8b 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -1,5 +1,13 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, SelectMenuInteraction } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ Message,
+ MessageActionRow,
+ MessageActionRowComponent,
+ MessageButton,
+ MessageComponentInteraction,
+ SelectMenuInteraction
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -7,22 +15,31 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
import createPageIndicator from "../../utils/createPageIndicator.js";
-
class Embed {
embed: Discord.MessageEmbed;
title: string;
description = "";
pageId = 0;
- setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
- setTitle(title: string) { this.title = title; return this; }
- setDescription(description: string) { this.description = description; return this; }
- setPageId(pageId: number) { this.pageId = pageId; return this; }
+ setEmbed(embed: Discord.MessageEmbed) {
+ this.embed = embed;
+ return this;
+ }
+ setTitle(title: string) {
+ this.title = title;
+ return this;
+ }
+ setDescription(description: string) {
+ this.description = description;
+ return this;
+ }
+ setPageId(pageId: number) {
+ this.pageId = pageId;
+ return this;
+ }
}
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("list")
- .setDescription("Lists all tags in the server");
+ builder.setName("list").setDescription("Lists all tags in the server");
const callback = async (interaction: CommandInteraction): Promise<void> => {
const data = await client.database.guilds.read(interaction.guild.id);
@@ -44,15 +61,24 @@
const pages = [];
for (const string of strings) {
- pages.push(new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("Tags")
- .setDescription(string)
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setStatus("Success")
- ).setTitle(`Page ${pages.length + 1}`).setPageId(pages.length));
+ pages.push(
+ new Embed()
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("Tags")
+ .setDescription(string)
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setStatus("Success")
+ )
+ .setTitle(`Page ${pages.length + 1}`)
+ .setPageId(pages.length)
+ );
}
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}) as Message;
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ })) as Message;
let page = 0;
let selectPaneOpen = false;
while (true) {
@@ -60,72 +86,150 @@
if (selectPaneOpen) {
const options = [];
- pages.forEach(embed => {
- options.push(new SelectMenuOption({
- label: embed.title,
- value: embed.pageId.toString(),
- description: embed.description || ""
- }));
+ pages.forEach((embed) => {
+ options.push(
+ new SelectMenuOption({
+ label: embed.title,
+ value: embed.pageId.toString(),
+ description: embed.description || ""
+ })
+ );
});
- selectPane = [new MessageActionRow().addComponents([
- new Discord.MessageSelectMenu()
- .addOptions(options)
- .setCustomId("page")
- .setMaxValues(1)
- .setPlaceholder("Choose a page...")
- ])];
+ selectPane = [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .addOptions(options)
+ .setCustomId("page")
+ .setMaxValues(1)
+ .setPlaceholder("Choose a page...")
+ ])
+ ];
}
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+ em.setDescription(
+ em.description + "\n\n" + createPageIndicator(pages.length, page)
+ );
await interaction.editReply({
embeds: [em],
- components: selectPane.concat([new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
- new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER")
- ])])
+ components: selectPane.concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("left")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(page === 0),
+ new MessageButton()
+ .setCustomId("select")
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
+ .setDisabled(false),
+ new MessageButton()
+ .setCustomId("right")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(page === pages.length - 1),
+ new MessageButton()
+ .setCustomId("close")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ ])
+ ])
});
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 === "left") {
if (page > 0) page--;
selectPaneOpen = false;
- } else if ((i.component as MessageActionRowComponent).customId === "right") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "right"
+ ) {
if (page < pages.length - 1) page++;
selectPaneOpen = false;
- } else if ((i.component as MessageActionRowComponent).customId === "select") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "select"
+ ) {
selectPaneOpen = !selectPaneOpen;
- } else if ((i.component as MessageActionRowComponent).customId === "page") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "page"
+ ) {
page = parseInt((i as SelectMenuInteraction).values[0]);
selectPaneOpen = false;
} else {
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
+ em.setDescription(
+ em.description +
+ "\n\n" +
+ createPageIndicator(pages.length, page) +
+ " | Message closed"
+ );
await interaction.editReply({
- embeds: [em], components: [new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
- ])]
+ embeds: [em],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("left")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("select")
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("right")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("close")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setDisabled(true)
+ ])
+ ]
});
return;
}
}
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
+ em.setDescription(
+ em.description +
+ "\n\n" +
+ createPageIndicator(pages.length, page) +
+ " | Message timed out"
+ );
await interaction.editReply({
embeds: [em],
- components: [new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
- new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
- ])]
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("left")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("select")
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("right")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setCustomId("close")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setDisabled(true)
+ ])
+ ]
});
};
diff --git a/src/commands/ticket/_meta.ts b/src/commands/ticket/_meta.ts
index 8c21466..e484928 100644
--- a/src/commands/ticket/_meta.ts
+++ b/src/commands/ticket/_meta.ts
@@ -1,4 +1,4 @@
const name = "ticket";
const description = "Manage modmail tickets";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index ed27abc..71044dd 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -3,9 +3,7 @@
import close from "../../actions/tickets/delete.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("close")
- .setDescription("Closes a ticket");
+ builder.setName("close").setDescription("Closes a ticket");
const callback = async (interaction: CommandInteraction): Promise<void> => {
await close(interaction);
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 55962d7..10ec842 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -6,7 +6,12 @@
builder
.setName("create")
.setDescription("Creates a new modmail ticket")
- .addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false));
+ .addStringOption((option) =>
+ option
+ .setName("message")
+ .setDescription("The content of the ticket")
+ .setRequired(false)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
await create(interaction);
diff --git a/src/commands/user/_meta.ts b/src/commands/user/_meta.ts
index 6c14052..8677d79 100644
--- a/src/commands/user/_meta.ts
+++ b/src/commands/user/_meta.ts
@@ -1,4 +1,4 @@
const name = "user";
const description = "Commands for user info";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index ede84b3..5f096ae 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,6 +1,18 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, SelectMenuInteraction } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ MessageActionRow,
+ MessageActionRowComponent,
+ MessageButton,
+ MessageComponentInteraction,
+ SelectMenuInteraction
+} from "discord.js";
+import {
+ SelectMenuOption,
+ SlashCommandSubcommandBuilder
+} from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
@@ -11,218 +23,320 @@
builder
.setName("about")
.setDescription("Shows info about a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"));
-
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription(
+ "The user to get info about | Default: Yourself"
+ )
+ );
class Embed {
embed: Discord.MessageEmbed;
title: string;
description = "";
pageId = 0;
- setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
- setTitle(title: string) { this.title = title; return this; }
- setDescription(description: string) { this.description = description; return this; }
- setPageId(pageId: number) { this.pageId = pageId; return this; }
+ setEmbed(embed: Discord.MessageEmbed) {
+ this.embed = embed;
+ return this;
+ }
+ setTitle(title: string) {
+ this.title = title;
+ return this;
+ }
+ setDescription(description: string) {
+ this.description = description;
+ return this;
+ }
+ setPageId(pageId: number) {
+ this.pageId = pageId;
+ return this;
+ }
}
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser, renderDelta } = client.logger;
- const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+ const member = (interaction.options.getMember("user") ||
+ interaction.member) as Discord.GuildMember;
const flags: string[] = [];
- if ([
- "438733159748599813", // Pinea
- "317731855317336067", // Mini
- "261900651230003201", // Coded
- "511655498676699136" // Zan
- ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER"); }
- if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter((m: GuildMember) => m.roles.cache.has("760896837866749972"))?.map((m: GuildMember) => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER"); }
- member.user.flags.toArray().map(flag => {
+ if (
+ [
+ "438733159748599813", // Pinea
+ "317731855317336067", // Mini
+ "261900651230003201", // Coded
+ "511655498676699136" // Zan
+ ].includes(member.user.id)
+ ) {
+ flags.push("NUCLEUSDEVELOPER");
+ }
+ if (
+ (await client.guilds.cache.get("684492926528651336")?.members.fetch())
+ ?.filter((m: GuildMember) =>
+ m.roles.cache.has("760896837866749972")
+ )
+ ?.map((m: GuildMember) => m.id)
+ .includes(member.user.id)
+ ) {
+ flags.push("CLICKSDEVELOPER");
+ }
+ member.user.flags.toArray().map((flag) => {
flags.push(flag.toString());
});
- if (member.user.bot === true) { flags.push("BOT"); }
+ if (member.user.bot) {
+ flags.push("BOT");
+ }
// Check if they are boosting the server
- if (member.premiumSince) { flags.push("BOOSTER"); }
+ if (member.premiumSince) {
+ flags.push("BOOSTER");
+ }
const nameReplacements = {
- "NUCLEUSDEVELOPER": "**Nucleus Developer**",
- "CLICKSDEVELOPER": "Clicks Developer",
- "HOUSE_BRAVERY": "Hypesquad Bravery",
- "HOUSE_BRILLIANCE": "Hypesquad Brilliance",
- "HOUSE_BALANCE": "Hypesquad Balance",
- "HYPESQUAD_EVENTS": "Hypesquad Events",
- "EARLY_SUPPORTER": "Early Supporter",
- "BUGHUNTER_LEVEL_1": "Bug Hunter Level 1",
- "BUGHUNTER_LEVEL_2": "Bug Hunter Level 2",
- "PARTNERED_SERVER_OWNER": "Partnered Server Owner",
- "DISCORD_EMPLOYEE": "Discord Staff",
- "EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer",
- "BOT": "Bot",
- "BOOSTER": "Server Booster"
+ NUCLEUSDEVELOPER: "**Nucleus Developer**",
+ CLICKSDEVELOPER: "Clicks Developer",
+ HOUSE_BRAVERY: "Hypesquad Bravery",
+ HOUSE_BRILLIANCE: "Hypesquad Brilliance",
+ HOUSE_BALANCE: "Hypesquad Balance",
+ HYPESQUAD_EVENTS: "Hypesquad Events",
+ EARLY_SUPPORTER: "Early Supporter",
+ BUGHUNTER_LEVEL_1: "Bug Hunter Level 1",
+ BUGHUNTER_LEVEL_2: "Bug Hunter Level 2",
+ PARTNERED_SERVER_OWNER: "Partnered Server Owner",
+ DISCORD_EMPLOYEE: "Discord Staff",
+ EARLY_VERIFIED_BOT_DEVELOPER: "Verified Bot Developer",
+ BOT: "Bot",
+ BOOSTER: "Server Booster"
};
const members = await interaction.guild.members.fetch();
const membersArray = [...members.values()];
membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp);
- const joinPos = membersArray.findIndex(m => m.id === member.user.id);
+ const joinPos = membersArray.findIndex((m) => m.id === member.user.id);
- const roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort();
+ const roles = member.roles.cache
+ .filter((r) => r.id !== interaction.guild.id)
+ .sort();
let s = "";
let count = 0;
let ended = false;
- roles.map(item => {
+ roles.map((item) => {
if (ended) return;
const string = `<@&${item.id}>, `;
- if(s.length + string.length > 1000) {
+ if (s.length + string.length > 1000) {
ended = true;
s += `and ${roles.size - count} more`;
return;
}
- count ++;
+ count++;
s += string;
});
- if(s.length > 0 && !ended) s = s.slice(0, -2);
+ if (s.length > 0 && !ended) s = s.slice(0, -2);
let perms = "";
const permsArray = {
- "ADMINISTRATOR": "Administrator",
- "MANAGE_GUILD": "Manage Server",
- "MANAGE_ROLES": "Manage Roles",
- "MANAGE_CHANNELS": "Manage Channels",
- "KICK_MEMBERS": "Kick Members",
- "BAN_MEMBERS": "Ban Members",
- "MODERATE_MEMBERS": "Moderate Members",
- "MANAGE_NICKNAMES": "Manage Nicknames",
- "MANAGE_WEBHOOKS": "Manage Webhooks",
- "MANAGE_MESSAGES": "Manage Messages",
- "VIEW_AUDIT_LOG": "View Audit Log",
- "MENTION_EVERYONE": "Mention Everyone"
+ ADMINISTRATOR: "Administrator",
+ MANAGE_GUILD: "Manage Server",
+ MANAGE_ROLES: "Manage Roles",
+ MANAGE_CHANNELS: "Manage Channels",
+ KICK_MEMBERS: "Kick Members",
+ BAN_MEMBERS: "Ban Members",
+ MODERATE_MEMBERS: "Moderate Members",
+ MANAGE_NICKNAMES: "Manage Nicknames",
+ MANAGE_WEBHOOKS: "Manage Webhooks",
+ MANAGE_MESSAGES: "Manage Messages",
+ VIEW_AUDIT_LOG: "View Audit Log",
+ MENTION_EVERYONE: "Mention Everyone"
};
- Object.keys(permsArray).map(perm => {
- const hasPerm = member.permissions.has(perm as Discord.PermissionString);
- perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`;
+ Object.keys(permsArray).map((perm) => {
+ const hasPerm = member.permissions.has(
+ perm as Discord.PermissionString
+ );
+ perms += `${getEmojiByName(
+ "CONTROL." + (hasPerm ? "TICK" : "CROSS")
+ )} ${permsArray[perm]}\n`;
});
let selectPaneOpen = false;
const embeds = [
new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("User Info: General")
- .setStatus("Success")
- .setEmoji("MEMBER.JOIN")
- .setDescription(
- flags.map(flag => {
- if (nameReplacements[flag]) {
- return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag];
- }
- }).join("\n") + "\n\n" +
- generateKeyValueList({
- "member": renderUser(member.user),
- "nickname": member.nickname || "*None set*",
- "id": `\`${member.id}\``,
- "joined the server": renderDelta(member.joinedTimestamp),
- "joined discord": renderDelta(member.user.createdTimestamp),
- "boost status": member.premiumSince ? `Started boosting ${renderDelta(member.premiumSinceTimestamp)}` : "*Not boosting*",
- "join position": `${joinPos + 1}`
- })
- )
- .setThumbnail(member.user.displayAvatarURL({dynamic: true}))
- .setImage((await member.user.fetch()).bannerURL({format: "gif"}))
- ).setTitle("General").setDescription("General information about the user").setPageId(0),
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("User Info: General")
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ .setDescription(
+ flags
+ .map((flag) => {
+ if (nameReplacements[flag]) {
+ return (
+ getEmojiByName(`BADGES.${flag}`) +
+ " " +
+ nameReplacements[flag]
+ );
+ }
+ })
+ .join("\n") +
+ "\n\n" +
+ generateKeyValueList({
+ member: renderUser(member.user),
+ nickname: member.nickname || "*None set*",
+ id: `\`${member.id}\``,
+ "joined the server": renderDelta(
+ member.joinedTimestamp
+ ),
+ "joined discord": renderDelta(
+ member.user.createdTimestamp
+ ),
+ "boost status": member.premiumSince
+ ? `Started boosting ${renderDelta(
+ member.premiumSinceTimestamp
+ )}`
+ : "*Not boosting*",
+ "join position": `${joinPos + 1}`
+ })
+ )
+ .setThumbnail(
+ member.user.displayAvatarURL({ dynamic: true })
+ )
+ .setImage(
+ (await member.user.fetch()).bannerURL({ format: "gif" })
+ )
+ )
+ .setTitle("General")
+ .setDescription("General information about the user")
+ .setPageId(0),
new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("User Info: Roles")
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- .setDescription(
- generateKeyValueList({
- "member": renderUser(member.user),
- "id": `\`${member.id}\``,
- "roles": `${member.roles.cache.size - 1}`
- }) + "\n" +
- (s.length > 0 ? s : "*None*") + "\n"
- )
- .setThumbnail(member.user.displayAvatarURL({dynamic: true}))
- ).setTitle("Roles").setDescription("Roles the user has").setPageId(1),
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("User Info: Roles")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setDescription(
+ generateKeyValueList({
+ member: renderUser(member.user),
+ id: `\`${member.id}\``,
+ roles: `${member.roles.cache.size - 1}`
+ }) +
+ "\n" +
+ (s.length > 0 ? s : "*None*") +
+ "\n"
+ )
+ .setThumbnail(
+ member.user.displayAvatarURL({ dynamic: true })
+ )
+ )
+ .setTitle("Roles")
+ .setDescription("Roles the user has")
+ .setPageId(1),
new Embed()
- .setEmbed(new EmojiEmbed()
- .setTitle("User Info: Key Permissions")
- .setStatus("Success")
- .setEmoji("GUILD.ROLES.CREATE")
- .setDescription(
- generateKeyValueList({
- "member": renderUser(member.user),
- "id": `\`${member.id}\``
- }) + "\n" + perms
- )
- .setThumbnail(member.user.displayAvatarURL({dynamic: true}))
- ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2)
+ .setEmbed(
+ new EmojiEmbed()
+ .setTitle("User Info: Key Permissions")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setDescription(
+ generateKeyValueList({
+ member: renderUser(member.user),
+ id: `\`${member.id}\``
+ }) +
+ "\n" +
+ perms
+ )
+ .setThumbnail(
+ member.user.displayAvatarURL({ dynamic: true })
+ )
+ )
+ .setTitle("Key Permissions")
+ .setDescription("Key permissions the user has")
+ .setPageId(2)
];
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}) as Message;
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ })) as Message;
let page = 0;
let breakReason = "";
while (true) {
const em = new Discord.MessageEmbed(embeds[page].embed);
- em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page));
+ em.setDescription(
+ em.description + "\n" + createPageIndicator(embeds.length, page)
+ );
let selectPane = [];
if (selectPaneOpen) {
const options = [];
- embeds.forEach(embed => {
- options.push(new SelectMenuOption({
- label: embed.title,
- value: embed.pageId.toString(),
- description: embed.description || ""
- }));
+ embeds.forEach((embed) => {
+ options.push(
+ new SelectMenuOption({
+ label: embed.title,
+ value: embed.pageId.toString(),
+ description: embed.description || ""
+ })
+ );
});
- selectPane = [new MessageActionRow().addComponents([
- new Discord.MessageSelectMenu()
- .addOptions(options)
- .setCustomId("page")
- .setMaxValues(1)
- .setPlaceholder("Choose a page...")
- ])];
+ selectPane = [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .addOptions(options)
+ .setCustomId("page")
+ .setMaxValues(1)
+ .setPlaceholder("Choose a page...")
+ ])
+ ];
}
await interaction.editReply({
embeds: [em],
- components: selectPane.concat([new MessageActionRow().addComponents([
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("SECONDARY")
- .setCustomId("left")
- .setDisabled(page === 0),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
- .setCustomId("select")
- .setDisabled(false),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setCustomId("right")
- .setStyle("SECONDARY")
- .setDisabled(page === embeds.length - 1),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("close")
- .setStyle("DANGER")
- ])])
+ components: selectPane.concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("left")
+ .setDisabled(page === 0),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
+ .setCustomId("select")
+ .setDisabled(false),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setCustomId("right")
+ .setStyle("SECONDARY")
+ .setDisabled(page === embeds.length - 1),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("close")
+ .setStyle("DANGER")
+ ])
+ ])
});
let i: MessageComponentInteraction;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch { breakReason = "Message timed out"; break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch {
+ breakReason = "Message timed out";
+ break;
+ }
i.deferUpdate();
if ((i.component as MessageActionRowComponent).customId === "left") {
if (page > 0) page--;
selectPaneOpen = false;
- } else if ((i.component as MessageActionRowComponent).customId === "right") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "right"
+ ) {
if (page < embeds.length - 1) page++;
selectPaneOpen = false;
- } else if ((i.component as MessageActionRowComponent).customId === "select") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "select"
+ ) {
selectPaneOpen = !selectPaneOpen;
- } else if ((i.component as MessageActionRowComponent).customId === "close") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "close"
+ ) {
breakReason = "Message closed";
break;
- } else if ((i.component as MessageActionRowComponent).customId === "page") {
+ } else if (
+ (i.component as MessageActionRowComponent).customId === "page"
+ ) {
page = parseInt((i as SelectMenuInteraction).values[0]);
selectPaneOpen = false;
} else {
@@ -231,29 +345,40 @@
}
}
const em = new Discord.MessageEmbed(embeds[page].embed);
- em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | " + breakReason);
- await interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("SECONDARY")
- .setCustomId("left")
- .setDisabled(true),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle("SECONDARY")
- .setCustomId("select")
- .setDisabled(true),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setCustomId("right")
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setCustomId("close")
- .setStyle("DANGER")
- .setDisabled(true)
- ])]});
+ em.setDescription(
+ em.description +
+ "\n" +
+ createPageIndicator(embeds.length, page) +
+ " | " +
+ breakReason
+ );
+ await interaction.editReply({
+ embeds: [em],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("left")
+ .setDisabled(true),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("select")
+ .setDisabled(true),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setCustomId("right")
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("close")
+ .setStyle("DANGER")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
const check = () => {
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index 8f327a5..35c475f 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -9,29 +9,44 @@
builder
.setName("avatar")
.setDescription("Shows the avatar of a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription(
+ "The user to get the avatar of | Default: Yourself"
+ )
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
- const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("User Info")
- .setStatus("Success")
- .setEmoji("MEMBER.JOIN")
- .setDescription(
- generateKeyValueList({
- "member": renderUser(member.user),
- "url": member.user.displayAvatarURL({dynamic: true})
- })
- )
- .setImage(await member.user.displayAvatarURL({dynamic: true}))
- ], ephemeral: true, fetchReply: true});
+ const member = (interaction.options.getMember("user") ||
+ interaction.member) as Discord.GuildMember;
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("User Info")
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ .setDescription(
+ generateKeyValueList({
+ member: renderUser(member.user),
+ url: member.user.displayAvatarURL({ dynamic: true })
+ })
+ )
+ .setImage(await member.user.displayAvatarURL({ dynamic: true }))
+ ],
+ ephemeral: true,
+ fetchReply: true
+ });
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 4720032..e0e41e0 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,8 +1,17 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
+import {
+ SelectMenuOption,
+ SlashCommandSubcommandBuilder
+} from "@discordjs/builders";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -13,24 +22,38 @@
builder
.setName("track")
.setDescription("Moves a user along a role track")
- .addUserOption(option => option.setName("user").setDescription("The user to manage").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to manage")
+ .setRequired(true)
+ );
-const generateFromTrack = (position: number, active: string | boolean, size: number, disabled: string | boolean) => {
+const generateFromTrack = (
+ position: number,
+ active: string | boolean,
+ size: number,
+ disabled: string | boolean
+) => {
active = active ? "ACTIVE" : "INACTIVE";
disabled = disabled ? "GREY." : "";
- if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active;
- if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
+ if (position === 0 && size === 1)
+ return "TRACKS.SINGLE." + disabled + active;
+ if (position === size - 1)
+ return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active;
return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
};
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
if (!guild) return;
const config = await client.database.guilds.read(guild.id);
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+ await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
let track = 0;
let generated;
const roles = await guild.roles.fetch();
@@ -38,119 +61,206 @@
let managed: boolean;
while (true) {
const data = config.tracks[track];
- if (data.manageableBy !== undefined) managed = data.manageableBy.some((element: string) => {return memberRoles.cache.has(element);});
- else managed = false;
- const dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
- const hasRoleInTrack = option.track.some((element: string) => {return memberRoles.cache.has(element);});
- return new SelectMenuOption({
- default: index === track,
- label: option.name,
- value: index.toString(),
- description: option.track.length === 0 ? "No" : addPlural(option.track.length, "role"),
- emoji: client.emojis.resolve(getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id"))
+ if (data.manageableBy !== undefined)
+ managed = data.manageableBy.some((element: string) => {
+ return memberRoles.cache.has(element);
});
- })).setCustomId("select").setMaxValues(1);
+ else managed = false;
+ const dropdown = new Discord.MessageSelectMenu()
+ .addOptions(
+ config.tracks.map((option, index) => {
+ const hasRoleInTrack = option.track.some(
+ (element: string) => {
+ return memberRoles.cache.has(element);
+ }
+ );
+ return new SelectMenuOption({
+ default: index === track,
+ label: option.name,
+ value: index.toString(),
+ description:
+ option.track.length === 0
+ ? "No"
+ : addPlural(option.track.length, "role"),
+ emoji: client.emojis.resolve(
+ getEmojiByName(
+ "TRACKS.SINGLE." +
+ (hasRoleInTrack ? "ACTIVE" : "INACTIVE"),
+ "id"
+ )
+ )
+ });
+ })
+ )
+ .setCustomId("select")
+ .setMaxValues(1);
const allowed = [];
- generated = "**Track:** " + data.name + "\n" + "**Member:** " + renderUser(member.user) + "\n";
- generated += (data.nullable ? "Members do not need a role in this track" : "A role in this track is required") + "\n";
- generated += (data.retainPrevious ? "When promoted, the user keeps previous roles" : "Members will lose their current role when promoted") + "\n";
- generated += "\n" + data.track.map((role, index) => {
- const allow = (roles.get(role).position >= (interaction.member as GuildMember).roles.highest.position) && !managed;
- allowed.push(!allow);
- return getEmojiByName(generateFromTrack(
- index,
- memberRoles.cache.has(role),
- data.track.length,
- allow
- )) + " " +
- roles.get(role).name + " [<@&" + roles.get(role).id + ">]";
- }).join("\n");
+ generated =
+ "**Track:** " +
+ data.name +
+ "\n" +
+ "**Member:** " +
+ renderUser(member.user) +
+ "\n";
+ generated +=
+ (data.nullable
+ ? "Members do not need a role in this track"
+ : "A role in this track is required") + "\n";
+ generated +=
+ (data.retainPrevious
+ ? "When promoted, the user keeps previous roles"
+ : "Members will lose their current role when promoted") + "\n";
+ generated +=
+ "\n" +
+ data.track
+ .map((role, index) => {
+ const allow =
+ roles.get(role).position >=
+ (interaction.member as GuildMember).roles.highest
+ .position && !managed;
+ allowed.push(!allow);
+ return (
+ getEmojiByName(
+ generateFromTrack(
+ index,
+ memberRoles.cache.has(role),
+ data.track.length,
+ allow
+ )
+ ) +
+ " " +
+ roles.get(role).name +
+ " [<@&" +
+ roles.get(role).id +
+ ">]"
+ );
+ })
+ .join("\n");
const selected = [];
for (let i = 0; i < data.track.length; i++) {
- if (memberRoles.cache.has(data.track[i])) selected.push(data.track[i]);
+ if (memberRoles.cache.has(data.track[i]))
+ selected.push(data.track[i]);
}
const conflict = data.retainPrevious ? false : selected.length > 1;
let conflictDropdown;
let currentRoleIndex;
if (conflict) {
- generated += `\n\n${getEmojiByName(`PUNISH.WARN.${managed ? "YELLOW" : "RED"}`)} This user has ${selected.length} roles from this track. `;
+ generated += `\n\n${getEmojiByName(
+ `PUNISH.WARN.${managed ? "YELLOW" : "RED"}`
+ )} This user has ${selected.length} roles from this track. `;
conflictDropdown = [];
if (
- (roles.get(selected[0]).position < memberRoles.highest.position) || managed
+ roles.get(selected[0]).position <
+ memberRoles.highest.position ||
+ managed
) {
- generated += "In order to promote or demote this user, you must select which role the member should keep.";
- selected.forEach(role => {
- conflictDropdown.push(new SelectMenuOption({
- label: roles.get(role).name,
- value: roles.get(role).id
- }));
+ generated +=
+ "In order to promote or demote this user, you must select which role the member should keep.";
+ selected.forEach((role) => {
+ conflictDropdown.push(
+ new SelectMenuOption({
+ label: roles.get(role).name,
+ value: roles.get(role).id
+ })
+ );
});
- conflictDropdown = [new Discord.MessageSelectMenu()
- .addOptions(conflictDropdown)
- .setCustomId("conflict")
- .setMaxValues(1)
- .setPlaceholder("Select a role to keep")];
+ conflictDropdown = [
+ new Discord.MessageSelectMenu()
+ .addOptions(conflictDropdown)
+ .setCustomId("conflict")
+ .setMaxValues(1)
+ .setPlaceholder("Select a role to keep")
+ ];
} else {
- generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep.";
+ generated +=
+ "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep.";
}
} else {
- currentRoleIndex = selected.length === 0 ? -1 : data.track.indexOf(selected[0].toString());
+ currentRoleIndex =
+ selected.length === 0
+ ? -1
+ : data.track.indexOf(selected[0].toString());
}
- const m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("TRACKS.ICON")
- .setTitle("Tracks")
- .setDescription(`${generated}`)
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents(dropdown)
- ]
- .concat(conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : [])
- .concat([
- new MessageActionRow().addComponents([
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.UP", "id"))
- .setLabel("Move up")
- .setCustomId("promote")
- .setStyle("SUCCESS")
- .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
- new MessageButton()
- .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
- .setLabel("Move down")
- .setCustomId("demote")
- .setStyle("DANGER")
- .setDisabled(conflict || (
- data.nullable ? currentRoleIndex <= -1 :
- currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
- ) || !allowed[currentRoleIndex])
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("TRACKS.ICON")
+ .setTitle("Tracks")
+ .setDescription(`${generated}`)
+ .setStatus("Success")
+ ],
+ components: [new MessageActionRow().addComponents(dropdown)]
+ .concat(
+ conflict && conflictDropdown.length
+ ? [
+ new MessageActionRow().addComponents(
+ conflictDropdown
+ )
+ ]
+ : []
+ )
+ .concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.UP", "id"))
+ .setLabel("Move up")
+ .setCustomId("promote")
+ .setStyle("SUCCESS")
+ .setDisabled(
+ conflict ||
+ currentRoleIndex === 0 ||
+ (currentRoleIndex === -1
+ ? false
+ : !allowed[currentRoleIndex - 1])
+ ),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
+ .setLabel("Move down")
+ .setCustomId("demote")
+ .setStyle("DANGER")
+ .setDisabled(
+ conflict ||
+ (data.nullable
+ ? currentRoleIndex <= -1
+ : currentRoleIndex ===
+ data.track.length - 1 ||
+ currentRoleIndex <= -1) ||
+ !allowed[currentRoleIndex]
+ )
+ ])
])
- ])
- }) as Message;
+ })) as Message;
let component;
try {
- component = await m.awaitMessageComponent({time: 300000});
+ component = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
return;
}
component.deferUpdate();
if (component.customId === "conflict") {
- const rolesToRemove = selected.filter(role => role !== component.values[0]);
+ const rolesToRemove = selected.filter(
+ (role) => role !== component.values[0]
+ );
await member.roles.remove(rolesToRemove);
} else if (component.customId === "promote") {
if (
- currentRoleIndex === -1 ? allowed[data.track.length - 1] :
- allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
+ currentRoleIndex === -1
+ ? allowed[data.track.length - 1]
+ : allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
) {
if (currentRoleIndex === -1) {
await member.roles.add(data.track[data.track.length - 1]);
} else if (currentRoleIndex < data.track.length) {
- if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex]);
+ if (!data.retainPrevious)
+ await member.roles.remove(data.track[currentRoleIndex]);
await member.roles.add(data.track[currentRoleIndex - 1]);
}
}
} else if (component.customId === "demote") {
- if(allowed[currentRoleIndex]) {
+ if (allowed[currentRoleIndex]) {
if (currentRoleIndex === data.track.length - 1) {
- if (data.nullable) await member.roles.remove(data.track[currentRoleIndex]);
+ if (data.nullable)
+ await member.roles.remove(data.track[currentRoleIndex]);
} else if (currentRoleIndex > -1) {
await member.roles.remove(data.track[currentRoleIndex]);
await member.roles.add(data.track[currentRoleIndex + 1]);
@@ -162,22 +272,32 @@
}
};
-const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const tracks = (await client.database.guilds.read(interaction.guild.id)).tracks;
+const check = async (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const tracks = (await client.database.guilds.read(interaction.guild.id))
+ .tracks;
if (tracks.length === 0) throw "This server does not have any tracks";
- const member = (interaction.member as GuildMember);
+ const member = interaction.member as GuildMember;
// Allow the owner to promote anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user can manage any of the tracks
let managed = false;
for (const element of tracks) {
if (!element.track.manageableBy) continue;
- if (!element.track.manageableBy.some(role => member.roles.cache.has(role))) continue;
+ if (
+ !element.track.manageableBy.some((role) =>
+ member.roles.cache.has(role)
+ )
+ )
+ continue;
managed = true;
break;
}
// Check if the user has manage_roles permission
- if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
+ if (!managed && !member.permissions.has("MANAGE_ROLES"))
+ throw "You do not have the *Manage Roles* permission";
// Allow track
return true;
};
@@ -185,4 +305,3 @@
export { command };
export { callback };
export { check };
-
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index f7e66b8..d1a0659 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,7 +1,7 @@
import type { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import { WrappedCheck } from "jshaiku";
import verify from "../reflex/verify.js";
@@ -13,7 +13,10 @@
verify(interaction);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};