some small tweaks
diff --git a/.editorconfig b/.editorconfig
index 9141329..a3284ca 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -6,3 +6,4 @@
charset = utf-8
indent_style = space
indent_size = 4
+max_line_length = 120
diff --git a/.eslintrc.json b/.eslintrc.json
index 5eed00e..59c8e80 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -5,11 +5,7 @@
"node": true
},
"ignorePatterns": ["dist/"],
- "extends": [
- "eslint:recommended",
- "plugin:@typescript-eslint/strict",
- "prettier"
- ],
+ "extends": ["eslint:recommended", "plugin:@typescript-eslint/strict", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
diff --git a/ClicksMigratingProblems/index.js b/ClicksMigratingProblems/index.js
index a9132f8..e5b302c 100644
--- a/ClicksMigratingProblems/index.js
+++ b/ClicksMigratingProblems/index.js
@@ -48,11 +48,7 @@
},
invite: {
enabled: data.invite ? data.invite.enabled : false,
- channels: data.invite
- ? data.invite.whitelist.channels.map((channel) =>
- channel.toString()
- )
- : []
+ channels: data.invite ? data.invite.whitelist.channels.map((channel) => channel.toString()) : []
},
pings: {
mass: 5,
@@ -66,11 +62,7 @@
message: null,
role: null
},
- role: data.welcome
- ? data.welcome.role !== null
- ? data.welcome.role.toString()
- : null
- : null,
+ role: data.welcome ? (data.welcome.role !== null ? data.welcome.role.toString() : null) : null,
channel: data.welcome
? data.welcome.message.text !== null
? data.welcome.message.channel.toString()
@@ -82,15 +74,11 @@
logging: {
logs: {
enabled: true,
- channel: data.log_info.log_channel
- ? data.log_info.log_channel.toString()
- : null,
+ channel: data.log_info.log_channel ? data.log_info.log_channel.toString() : null,
toLog: "3fffff"
},
staff: {
- channel: data.log_info.staff
- ? data.log_info.staff.toString()
- : null
+ channel: data.log_info.staff ? data.log_info.staff.toString() : null
}
},
verify: {
@@ -99,18 +87,10 @@
},
tickets: {
enabled: data.modmail ? data.modmail.cat !== null : null,
- category: data.modmail
- ? data.modmail.cat !== null
- ? data.modmail.cat.toString()
- : null
- : null,
+ category: data.modmail ? (data.modmail.cat !== null ? data.modmail.cat.toString() : null) : null,
types: "3f",
customTypes: null,
- supportRole: data.modmail
- ? data.modmail.mention !== null
- ? data.modmail.mention.toString()
- : null
- : null,
+ supportRole: data.modmail ? (data.modmail.mention !== null ? data.modmail.mention.toString() : null) : null,
maxTickets: data.modmail ? data.modmail.max : 5
},
moderation: {
@@ -145,11 +125,7 @@
tags: data.tags
};
// Insert the new data into the database
- await collection.updateOne(
- { id: data.guild_info.id.toString() },
- { $set: newData },
- { upsert: true }
- );
+ await collection.updateOne({ id: data.guild_info.id.toString() }, { $set: newData }, { upsert: true });
// Delete the old file
fs.unlinkSync(`./oldData/${file}`);
console.log(`└ Successfully migrated file ${file}`);
diff --git a/ClicksMigratingProblems/randomPunishments.js b/ClicksMigratingProblems/randomPunishments.js
index 4ea01d2..af9c908 100644
--- a/ClicksMigratingProblems/randomPunishments.js
+++ b/ClicksMigratingProblems/randomPunishments.js
@@ -7,50 +7,21 @@
for (let i = 0; i < 100; i++) {
// Select a type
- let type = [
- "join",
- "unban",
- "leave",
- "ban",
- "softban",
- "kick",
- "mute",
- "purge",
- "warn",
- "nickname"
- ][Math.floor(Math.random() * 9)];
+ let type = ["join", "unban", "leave", "ban", "softban", "kick", "mute", "purge", "warn", "nickname"][
+ Math.floor(Math.random() * 9)
+ ];
// Select a random date in the last year
- let date = new Date(
- new Date().getTime() - Math.floor(Math.random() * 31536000000)
- );
+ let date = new Date(new Date().getTime() - Math.floor(Math.random() * 31536000000));
// Add to database
await collection.insertOne({
type: type,
occurredAt: date,
user: "438733159748599813",
guild: "864185037078790195",
- moderator: [
- "unban",
- "ban",
- "softban",
- "kick",
- "mute",
- "purge",
- "warn"
- ].includes(type)
+ moderator: ["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type)
? "438733159748599813"
: null,
- reason: [
- "unban",
- "ban",
- "softban",
- "kick",
- "mute",
- "purge",
- "warn"
- ].includes(type)
- ? "Test"
- : null,
+ reason: ["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type) ? "Test" : null,
before: type === "nickname" ? "TestBefore" : null,
after: type === "nickname" ? "TestAfter" : null,
amount: type === "purge" ? Math.floor(Math.random() * 100) : null
diff --git a/Installer.js b/Installer.js
index 0a93596..6ce907a 100644
--- a/Installer.js
+++ b/Installer.js
@@ -1,9 +1,12 @@
let format;
try {
- format = await import("./dist/config/format.js");
+ format = (await import("./dist/config/format.js")).default;
} catch (e) {
console.log("Please run `yarn` and `yarn build` first.");
+ process.exit(1);
}
await format(true);
process.exit(0);
+
+export {};
diff --git a/package.json b/package.json
index 7a0052d..09e29b7 100644
--- a/package.json
+++ b/package.json
@@ -32,7 +32,8 @@
"force-dev": "rm -rf dist && eslint . --fix; tsc-suppress && node --experimental-json-modules --enable-source-maps dist/index.js",
"lint": "echo 'Style checking...'; prettier --check .; echo 'Linting...'; eslint .; echo 'To auto-fix everything possible, please run `yarn lint-fix`'; true",
"lint-fix": "echo 'Fixing eslint issues...'; eslint . --fix; echo 'Reformatting...'; prettier --write --loglevel warn --cache .; true",
- "lint-list": "echo 'Style checking...'; prettier --check .; echo 'Linting...'; eslint .; echo 'To view errors in more detail, please run `yarn lint`; true"
+ "lint-list": "echo 'Style checking...'; prettier --check .; echo 'Linting...'; eslint .; echo 'To view errors in more detail, please run `yarn lint`; true",
+ "setup": "node Installer.js"
},
"repository": {
"type": "git",
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 453a467..1c6ce20 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -23,11 +23,7 @@
data: object;
checkFunction: (member) => boolean;
inverted = false;
- constructor(
- name: (data) => string | string,
- data: object,
- check: (member) => boolean
- ) {
+ constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
if (typeof name === "function") {
this.name = name(data);
} else {
@@ -64,10 +60,7 @@
render: "joined",
before: (date) =>
new Filter(
- (_data) =>
- `Joined server before <t:${Math.round(
- date.getTime() / 1000
- )}:D>`,
+ (_data) => `Joined server before <t:${Math.round(date.getTime() / 1000)}:D>`,
{ date: date, type: Date, render: "before" },
(member) => {
return member.joinedTimestamp < date.getTime();
@@ -116,10 +109,7 @@
render: "created",
before: (date) =>
new Filter(
- (_data) =>
- `Account created before <t:${Math.round(
- date.getTime() / 1000
- )}:D>`,
+ (_data) => `Account created before <t:${Math.round(date.getTime() / 1000)}:D>`,
{ date: date, type: Date, render: "before" },
(member) => {
return member.user.createdTimestamp < date.getTime();
@@ -167,9 +157,7 @@
}
};
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -215,29 +203,20 @@
new EmojiEmbed()
.setTitle("Role all")
.setDescription(
- (all
- ? "All of the following must be true:"
- : "Any of the following must be true") +
+ (all ? "All of the following must be true:" : "Any of the following must be true") +
"\n" +
filters
.map((f) => {
count++;
return (
- (count === 1
- ? getEmojiByName("ICONS.FILTER")
- : all
- ? "**and** "
- : "**or** ") +
+ (count === 1 ? getEmojiByName("ICONS.FILTER") : all ? "**and** " : "**or** ") +
(f.inverted ? "**not** " : "") +
`${f.name}`
);
})
.join("\n") +
"\n\n" +
- `This will affect ${addPlural(
- affected.length,
- "member"
- )}`
+ `This will affect ${addPlural(affected.length, "member")}`
)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success")
@@ -261,21 +240,13 @@
.setLabel("Apply")
.setStyle("PRIMARY")
.setCustomId("apply")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("CONTROL.TICK", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
.setDisabled(affected.length === 0),
new MessageButton()
.setLabel("Add filter")
.setStyle("PRIMARY")
.setCustomId("add")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.FILTER", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
.setDisabled(filters.length >= 25)
])
]
@@ -285,19 +256,14 @@
return;
};
-const check = async (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
const member = interaction.member as GuildMember;
const me = interaction.guild.me!;
- 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;
};
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index 8c25eb2..2da2be3 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,11 +1,5 @@
import { LoadingEmbed } from "../utils/defaultEmbeds.js";
-import {
- CommandInteraction,
- GuildChannel,
- MessageActionRow,
- MessageButton,
- MessageSelectMenu
-} from "discord.js";
+import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
// @ts-expect-error
import type { WrappedCheck } from "jshaiku";
@@ -14,14 +8,10 @@
import addPlural from "../utils/plurals.js";
import getEmojiByName from "../utils/getEmojiByName.js";
-const command = new SlashCommandBuilder()
- .setName("categorise")
- .setDescription("Categorises your servers channels");
+const command = new SlashCommandBuilder().setName("categorise").setDescription("Categorises your servers channels");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const channels = interaction.guild.channels.cache.filter(
- (c) => c.type !== "GUILD_CATEGORY"
- );
+ const channels = interaction.guild.channels.cache.filter((c) => c.type !== "GUILD_CATEGORY");
const categorised = {};
await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
const predicted = {};
@@ -50,10 +40,7 @@
for (const c of channels) {
// convert channel to a channel if its a string
let channel: string | GuildChannel;
- if (typeof c === "string")
- channel = interaction.guild.channels.cache.get(
- channel as string
- ).id;
+ if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel as string).id;
else channel = (c[0] as unknown as GuildChannel).id;
console.log(channel);
if (!predicted[channel]) predicted[channel] = [];
@@ -63,10 +50,7 @@
.setTitle("Categorise")
.setDescription(
`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(
- predicted[channel].length,
- "Suggestion"
- )}: ${predicted[channel].join(", ")}`
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`
)
.setEmoji("CHANNEL.CATEGORY.CREATE")
.setStatus("Success")
@@ -77,9 +61,7 @@
.setCustomId("selected")
.setMaxValues(Object.keys(types).length)
.setMinValues(1)
- .setPlaceholder(
- "Select all types that apply to this channel"
- )
+ .setPlaceholder("Select all types that apply to this channel")
.setOptions(
Object.keys(types).map((type) => ({
label: type,
@@ -93,20 +75,12 @@
.setCustomId("accept")
.setStyle("SUCCESS")
.setDisabled(predicted[channel].length === 0)
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.TICK", "id")
- )
- ),
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
new MessageButton()
.setLabel('Use "Other"')
.setCustomId("reject")
.setStyle("SECONDARY")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.CROSS", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
])
]
});
@@ -122,10 +96,9 @@
.setStatus("Danger")
.setDescription(
`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(
- predicted[channel].length,
- "Suggestion"
- )}: ${predicted[channel].join(", ")}`
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(
+ ", "
+ )}`
)
.setFooter({ text: "Message timed out" })
]
@@ -147,10 +120,7 @@
console.log(categorised);
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/actions/createModActionTicket.ts b/src/actions/createModActionTicket.ts
index 41f949c..0eca621 100644
--- a/src/actions/createModActionTicket.ts
+++ b/src/actions/createModActionTicket.ts
@@ -11,24 +11,11 @@
customReason?: string
) {
const config = await client.database.guilds.read(guild.id);
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderChannel,
- renderDelta
- } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
const overwrites = [
{
id: member,
- allow: [
- "VIEW_CHANNEL",
- "SEND_MESSAGES",
- "ATTACH_FILES",
- "ADD_REACTIONS",
- "READ_MESSAGE_HISTORY"
- ],
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
type: "member"
}
] as Discord.OverwriteResolvable[];
@@ -40,13 +27,7 @@
if (config.tickets.supportRole !== null) {
overwrites.push({
id: guild.roles.cache.get(config.tickets.supportRole),
- allow: [
- "VIEW_CHANNEL",
- "SEND_MESSAGES",
- "ATTACH_FILES",
- "ADD_REACTIONS",
- "READ_MESSAGE_HISTORY"
- ],
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
type: "role"
});
}
@@ -67,16 +48,10 @@
try {
await c.send({
content:
- `<@${member.id}>` +
- (config.tickets.supportRole !== null
- ? ` • <@&${config.tickets.supportRole}>`
- : ""),
+ `<@${member.id}>` + (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : ""),
allowedMentions: {
users: [member.id],
- roles:
- config.tickets.supportRole !== null
- ? [config.tickets.supportRole]
- : []
+ roles: config.tickets.supportRole !== null ? [config.tickets.supportRole] : []
}
});
await c.send({
@@ -85,14 +60,8 @@
.setTitle("New Ticket")
.setDescription(
"Ticket created by a Moderator\n" +
- `**Support type:** ${
- customReason
- ? customReason
- : "Appeal submission"
- }\n` +
- (reason !== null
- ? `**Reason:**\n> ${reason}\n`
- : "") +
+ `**Support type:** ${customReason ? customReason : "Appeal submission"}\n` +
+ (reason !== null ? `**Reason:**\n> ${reason}\n` : "") +
`**Ticket ID:** \`${c.id}\`\n` +
"Type `/ticket close` to close this ticket."
)
@@ -121,10 +90,7 @@
list: {
ticketFor: entry(member.id, renderUser(member)),
createdBy: entry(createdBy.id, renderUser(createdBy)),
- created: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
ticketChannel: entry(c.id, renderChannel(c))
},
hidden: {
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index dc224e8..e7f1874 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -1,11 +1,22 @@
-import { MessageButton } from "discord.js";
+import { Interaction, MessageButton } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import { MessageActionRow, MessageSelectMenu } from "discord.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js";
import { LoadingEmbed } from "../utils/defaultEmbeds.js";
+import type { GuildConfig } from "../utils/database.js";
-export async function callback(interaction) {
+export interface RoleMenuSchema {
+ guild: string;
+ guildName: string;
+ guildIcon: string;
+ user: string;
+ username: string;
+ data: GuildConfig["roleMenu"]["options"];
+ interaction: Interaction;
+}
+
+export async function callback(interaction: Interaction) {
const config = await client.database.guilds.read(interaction.guild.id);
if (!config.roleMenu.enabled)
return await interaction.reply({
@@ -25,9 +36,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Roles")
- .setDescription(
- "There are no roles available. Please contact a staff member or try again later."
- )
+ .setDescription("There are no roles available. Please contact a staff member or try again later.")
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
],
@@ -39,8 +48,7 @@
let code = "";
let length = 5;
let itt = 0;
- const chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let valid = false;
while (!valid) {
itt += 1;
@@ -66,14 +74,13 @@
interaction: interaction
};
let up = true;
- try {
- const status = await fetch(client.config.baseUrl).then(
- (res) => res.status
- );
+ up = false; // FIXME: Role menu does not yet exist, so the web UI is never up
+ /* try {
+ const status = await fetch(client.config.baseUrl).then((res) => res.status);
if (status !== 200) up = false;
} catch {
up = false;
- }
+ }*/
m = await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -88,13 +95,8 @@
.setLabel("Online")
.setStyle("LINK")
.setDisabled(!up)
- .setURL(
- `${client.config.baseUrl}nucleus/rolemenu?code=${code}`
- ),
- new MessageButton()
- .setLabel("Manual")
- .setStyle("PRIMARY")
- .setCustomId("manual")
+ .setURL(`${client.config.baseUrl}nucleus/rolemenu?code=${code}`),
+ new MessageButton().setLabel("Manual").setStyle("PRIMARY").setCustomId("manual")
])
]
});
@@ -116,13 +118,9 @@
.setEmoji("GUILD.GREEN")
.setDescription(
`**${object.name}**` +
- (object.description
- ? `\n${object.description}`
- : "") +
+ (object.description ? `\n${object.description}` : "") +
`\n\nSelect ${object.min}` +
- (object.min !== object.max
- ? ` to ${object.max}`
- : "") +
+ (object.min !== object.max ? ` to ${object.max}` : "") +
` role${object.max === 1 ? "" : "s"} to add.`
)
.setStatus("Success")
@@ -145,9 +143,7 @@
.setLabel("Skip")
.setStyle("SECONDARY")
.setCustomId("skip")
- .setEmoji(
- getEmojiByName("CONTROL.RIGHT", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
]
: []
)
@@ -193,13 +189,9 @@
});
}
}
- let rolesToRemove = config.roleMenu.options
- .map((o) => o.options.map((o) => o.role))
- .flat();
+ let rolesToRemove = config.roleMenu.options.map((o) => o.options.map((o) => o.role)).flat();
const memberRoles = interaction.member.roles.cache.map((r) => r.id);
- rolesToRemove = rolesToRemove
- .filter((r) => memberRoles.includes(r))
- .filter((r) => !rolesToAdd.includes(r));
+ rolesToRemove = rolesToRemove.filter((r) => memberRoles.includes(r)).filter((r) => !rolesToAdd.includes(r));
rolesToAdd = rolesToAdd.filter((r) => !memberRoles.includes(r));
try {
await interaction.member.roles.remove(rolesToRemove);
@@ -222,9 +214,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Roles")
- .setDescription(
- "Roles have been added. You may close this message."
- )
+ .setDescription("Roles have been added. You may close this message.")
.setStatus("Success")
.setEmoji("GUILD.GREEN")
],
diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index ca5147a..d6bf822 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -6,20 +6,11 @@
function capitalize(s: string) {
s = s.replace(/([A-Z])/g, " $1");
- return s.length < 3
- ? s.toUpperCase()
- : s[0].toUpperCase() + s.slice(1).toLowerCase();
+ return s.length < 3 ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
}
export default async function (interaction) {
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderChannel,
- renderDelta
- } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
const config = await client.database.guilds.read(interaction.guild.id);
if (!config.tickets.enabled || !config.tickets.category) {
@@ -27,9 +18,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tickets are disabled")
- .setDescription(
- "Please enable tickets in the configuration to use this command."
- )
+ .setDescription("Please enable tickets in the configuration to use this command.")
.setFooter({
text: interaction.member.permissions.has("MANAGE_GUILD")
? "You can enable it by running /settings tickets"
@@ -41,17 +30,11 @@
ephemeral: true
});
}
- const category = interaction.guild.channels.cache.get(
- config.tickets.category
- ) as Discord.CategoryChannel;
+ const category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
let count = 0;
category.children.forEach((element) => {
if (!(element.type === "GUILD_TEXT")) return;
- if (
- (element as Discord.TextChannel).topic.includes(
- `${interaction.member.user.id}`
- )
- ) {
+ if ((element as Discord.TextChannel).topic.includes(`${interaction.member.user.id}`)) {
if ((element as Discord.TextChannel).topic.endsWith("Active")) {
count++;
}
@@ -76,8 +59,7 @@
if (config.tickets.customTypes && config.tickets.useCustom) {
ticketTypes = config.tickets.customTypes;
custom = true;
- } else if (config.tickets.types)
- ticketTypes = toHexArray(config.tickets.types, tickets);
+ } else if (config.tickets.types) ticketTypes = toHexArray(config.tickets.types, tickets);
else ticketTypes = [];
let chosenType;
let splitFormattedTicketTypes = [];
@@ -85,29 +67,17 @@
let formattedTicketTypes = [];
formattedTicketTypes = ticketTypes.map((type) => {
if (custom) {
- return new MessageButton()
- .setLabel(type)
- .setStyle("PRIMARY")
- .setCustomId(type);
+ return new MessageButton().setLabel(type).setStyle("PRIMARY").setCustomId(type);
} else {
return new MessageButton()
.setLabel(capitalize(type))
.setStyle("PRIMARY")
.setCustomId(type)
- .setEmoji(
- getEmojiByName(
- "TICKETS." + type.toString().toUpperCase(),
- "id"
- )
- );
+ .setEmoji(getEmojiByName("TICKETS." + type.toString().toUpperCase(), "id"));
}
});
for (let i = 0; i < formattedTicketTypes.length; i += 5) {
- splitFormattedTicketTypes.push(
- new MessageActionRow().addComponents(
- formattedTicketTypes.slice(i, i + 5)
- )
- );
+ splitFormattedTicketTypes.push(new MessageActionRow().addComponents(formattedTicketTypes.slice(i, i + 5)));
}
const m = await interaction.reply({
embeds: [
@@ -142,21 +112,12 @@
.setLabel(capitalize(type))
.setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
.setCustomId(type)
- .setEmoji(
- getEmojiByName(
- "TICKETS." + type.toString().toUpperCase(),
- "id"
- )
- )
+ .setEmoji(getEmojiByName("TICKETS." + type.toString().toUpperCase(), "id"))
.setDisabled(true);
}
});
for (let i = 0; i < formattedTicketTypes.length; i += 5) {
- splitFormattedTicketTypes.push(
- new MessageActionRow().addComponents(
- formattedTicketTypes.slice(i, i + 5)
- )
- );
+ splitFormattedTicketTypes.push(new MessageActionRow().addComponents(formattedTicketTypes.slice(i, i + 5)));
}
component.update({
embeds: [
@@ -171,11 +132,7 @@
} else {
chosenType = null;
await interaction.reply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Create Ticket")
- .setEmoji("GUILD.TICKET.OPEN")
- ],
+ embeds: [new EmojiEmbed().setTitle("Create Ticket").setEmoji("GUILD.TICKET.OPEN")],
ephemeral: true,
components: splitFormattedTicketTypes
});
@@ -183,13 +140,7 @@
const overwrites = [
{
id: interaction.member,
- allow: [
- "VIEW_CHANNEL",
- "SEND_MESSAGES",
- "ATTACH_FILES",
- "ADD_REACTIONS",
- "READ_MESSAGE_HISTORY"
- ],
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
type: "member"
}
] as Discord.OverwriteResolvable[];
@@ -201,31 +152,21 @@
if (config.tickets.supportRole !== null) {
overwrites.push({
id: interaction.guild.roles.cache.get(config.tickets.supportRole),
- allow: [
- "VIEW_CHANNEL",
- "SEND_MESSAGES",
- "ATTACH_FILES",
- "ADD_REACTIONS",
- "READ_MESSAGE_HISTORY"
- ],
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
type: "role"
});
}
let c;
try {
- c = await interaction.guild.channels.create(
- interaction.member.user.username,
- {
- type: "GUILD_TEXT",
- topic: `${interaction.member.user.id} Active`,
- parent: config.tickets.category,
- nsfw: false,
- permissionOverwrites:
- overwrites as Discord.OverwriteResolvable[],
- reason: "Creating ticket"
- }
- );
+ c = await interaction.guild.channels.create(interaction.member.user.username, {
+ type: "GUILD_TEXT",
+ topic: `${interaction.member.user.id} Active`,
+ parent: config.tickets.category,
+ nsfw: false,
+ permissionOverwrites: overwrites as Discord.OverwriteResolvable[],
+ reason: "Creating ticket"
+ });
} catch (e) {
return await interaction.editReply({
embeds: [
@@ -241,24 +182,15 @@
await c.send({
content:
`<@${interaction.member.user.id}>` +
- (config.tickets.supportRole !== null
- ? ` • <@&${config.tickets.supportRole}>`
- : ""),
+ (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : ""),
allowedMentions: {
users: [(interaction.member as Discord.GuildMember).id],
- roles:
- config.tickets.supportRole !== null
- ? [config.tickets.supportRole]
- : []
+ roles: config.tickets.supportRole !== null ? [config.tickets.supportRole] : []
}
});
- let content = interaction.options
- ? interaction.options.getString("message") || ""
- : "";
+ let content = interaction.options ? interaction.options.getString("message") || "" : "";
if (content) content = `**Message:**\n> ${content}\n`;
- const emoji = custom
- ? ""
- : getEmojiByName("TICKETS." + chosenType.toUpperCase());
+ const emoji = custom ? "" : getEmojiByName("TICKETS." + chosenType.toUpperCase());
await c.send({
embeds: [
new EmojiEmbed()
@@ -266,9 +198,7 @@
.setDescription(
`Ticket created by <@${interaction.member.user.id}>\n` +
`**Support type:** ${
- chosenType !== null
- ? emoji + " " + capitalize(chosenType)
- : "General"
+ chosenType !== null ? emoji + " " + capitalize(chosenType) : "General"
}\n` +
`**Ticket ID:** \`${c.id}\`\n${content}\n` +
"Type `/ticket close` to close this ticket."
@@ -296,14 +226,8 @@
timestamp: new Date().getTime()
},
list: {
- ticketFor: entry(
- interaction.member.user.id,
- renderUser(interaction.member.user)
- ),
- created: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ ticketFor: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
ticketChannel: entry(c.id, renderChannel(c))
},
hidden: {
@@ -318,9 +242,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Create Ticket")
- .setDescription(
- `Ticket created. You can view it here: <#${c.id}>`
- )
+ .setDescription(`Ticket created. You can view it here: <#${c.id}>`)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index 6509c03..d692a1e 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -4,14 +4,7 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
export default async function (interaction) {
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderChannel,
- renderDelta
- } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
const config = await client.database.guilds.read(interaction.guild.id);
let thread = false;
@@ -21,9 +14,7 @@
if (
!channel.parent ||
config.tickets.category !== channel.parent.id ||
- (thread
- ? threadChannel.parent.parent.id !== config.tickets.category
- : false)
+ (thread ? threadChannel.parent.parent.id !== config.tickets.category : false)
) {
return interaction.reply({
embeds: [
@@ -61,22 +52,10 @@
list: {
ticketFor: entry(
channel.topic.split(" ")[0],
- renderUser(
- (
- await interaction.guild.members.fetch(
- channel.topic.split(" ")[0]
- )
- ).user
- )
+ renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)
),
- deletedBy: entry(
- interaction.member.user.id,
- renderUser(interaction.member.user)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ deletedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {
guild: interaction.guild.id
@@ -109,16 +88,8 @@
] as Discord.OverwriteResolvable[];
if (config.tickets.supportRole !== null) {
overwrites.push({
- id: interaction.guild.roles.cache.get(
- config.tickets.supportRole
- ),
- allow: [
- "VIEW_CHANNEL",
- "SEND_MESSAGES",
- "ATTACH_FILES",
- "ADD_REACTIONS",
- "READ_MESSAGE_HISTORY"
- ],
+ id: interaction.guild.roles.cache.get(config.tickets.supportRole),
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
type: "role"
});
}
@@ -136,22 +107,10 @@
list: {
ticketFor: entry(
channel.topic.split(" ")[0],
- renderUser(
- (
- await interaction.guild.members.fetch(
- channel.topic.split(" ")[0]
- )
- ).user
- )
+ renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)
),
- closedBy: entry(
- interaction.member.user.id,
- renderUser(interaction.member.user)
- ),
- closed: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ closed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
ticketChannel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -184,12 +143,7 @@
.setLabel("Create Transcript and Delete")
.setStyle("PRIMARY")
.setCustomId("createtranscript")
- .setEmoji(
- getEmojiByName(
- "CONTROL.DOWNLOAD",
- "id"
- )
- )
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
]
: []
)
@@ -219,8 +173,7 @@
}
});
if (deleted) {
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- member.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
const data = {
meta: {
type: "ticketPurge",
@@ -233,10 +186,7 @@
list: {
ticketFor: entry(member, renderUser(member)),
deletedBy: entry(null, "Member left server"),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
ticketsDeleted: deleted
},
hidden: {
diff --git a/src/api/index.ts b/src/api/index.ts
index 2c4baba..f77fe70 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -105,15 +105,11 @@
const code = req.params.code;
const secret = req.body.secret;
if (secret === client.config.verifySecret) {
- const guild = await client.guilds.fetch(
- client.roleMenu[code].guild
- );
+ const guild = await client.guilds.fetch(client.roleMenu[code].guild);
if (!guild) {
return res.status(404);
}
- const member = await guild.members.fetch(
- client.roleMenu[code].user
- );
+ const member = await guild.members.fetch(client.roleMenu[code].user);
if (!member) {
return res.status(404);
}
diff --git a/src/commands/help.ts b/src/commands/help.ts
index 921318e..df44aaa 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -2,18 +2,13 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-const command = new SlashCommandBuilder()
- .setName("help")
- .setDescription("Shows help for commands");
+const command = new SlashCommandBuilder().setName("help").setDescription("Shows help for commands");
const callback = async (interaction: CommandInteraction): Promise<void> => {
interaction.reply("hel p"); // TODO: FINISH THIS FOR RELEASE
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 4560c8b..87bfd28 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,9 +1,4 @@
-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";
@@ -15,12 +10,7 @@
builder
.setName("ban")
.setDescription("Bans a user from the server")
- .addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to ban")
- .setRequired(true)
- )
+ .addUserOption((option) => option.setName("user").setDescription("The user to ban").setRequired(true))
.addNumberOption((option) =>
option
.setName("delete")
@@ -43,21 +33,14 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")),
- reason: reason
- ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
- : "*No reason provided*"
+ 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,
+ 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
- }>?`
+ `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addReasonButton(reason ?? "")
@@ -66,8 +49,7 @@
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;
@@ -75,9 +57,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -112,15 +92,8 @@
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",
@@ -133,22 +106,10 @@
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: {
@@ -162,9 +123,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
- .setDescription(
- "Something went wrong and the user was not banned"
- )
+ .setDescription("Something went wrong and the user was not banned")
.setStatus("Danger")
],
components: []
@@ -178,10 +137,7 @@
new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle("Ban")
- .setDescription(
- "The member was banned" +
- (failed ? ", but could not be notified" : "")
- )
+ .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
],
components: []
@@ -204,30 +160,24 @@
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";
+ 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;
};
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 9837273..af30989 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -18,10 +18,7 @@
.setName("info")
.setDescription("Shows moderator information about a user")
.addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to get information about")
- .setRequired(true)
+ option.setName("user").setDescription("The user to get information about").setRequired(true)
);
const types = {
@@ -39,11 +36,9 @@
};
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>`;
+ 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}>`;
}
@@ -71,13 +66,8 @@
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
- );
+ 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>`);
}
@@ -109,22 +99,14 @@
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)
- );
+ history = history.filter((h) => tempFilteredTypes.includes(h.type));
}
refresh = false;
}
@@ -132,11 +114,7 @@
if (history.length > 0) {
current = new TimelineSection();
history.forEach((event) => {
- if (
- current.contentLength() + historyToString(event).length >
- 2000 ||
- current.content.length === 5
- ) {
+ if (current.contentLength() + historyToString(event).length > 2000 || current.content.length === 5) {
groups.push(current);
current.generateName();
current = new TimelineSection();
@@ -162,9 +140,7 @@
label: value.text,
value: key,
default: filteredTypes.includes(key),
- emoji: client.emojis.resolve(
- getEmojiByName(value.emoji, "id")
- )
+ emoji: client.emojis.resolve(getEmojiByName(value.emoji, "id"))
}))
)
.setMinValues(1)
@@ -181,22 +157,13 @@
.setLabel((currentYear - 1).toString())
.setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
.setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("prevPage")
- .setLabel("Previous page")
- .setStyle("PRIMARY"),
- new MessageButton()
- .setCustomId("today")
- .setLabel("Today")
- .setStyle("PRIMARY"),
+ new MessageButton().setCustomId("prevPage").setLabel("Previous page").setStyle("PRIMARY"),
+ new MessageButton().setCustomId("today").setLabel("Today").setStyle("PRIMARY"),
new MessageButton()
.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())
@@ -220,13 +187,8 @@
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") +
+ 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) {
@@ -235,22 +197,13 @@
embeds: [
new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
- .setTitle(
- "Moderation history for " + member.user.username
- )
+ .setTitle("Moderation history for " + member.user.username)
.setDescription(
- `**${toRender.name}**\n\n` +
- toRender.content
- .map((c) => c.rendered)
- .join("\n") +
- end
+ `**${toRender.name}**\n\n` + toRender.content.map((c) => c.rendered).join("\n") + end
)
.setStatus("Success")
.setFooter({
- text:
- openFilterPane && filteredTypes.length
- ? "Filters are currently enabled"
- : ""
+ text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : ""
})
],
components: components
@@ -260,18 +213,11 @@
embeds: [
new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
- .setTitle(
- "Moderation history for " + member.user.username
- )
- .setDescription(
- `**${currentYear}**\n\n*No events*` + "\n\n" + end
- )
+ .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"
- : ""
+ text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : ""
})
],
components: components
@@ -285,9 +231,7 @@
embeds: [
new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
- .setTitle(
- "Moderation history for " + member.user.username
- )
+ .setTitle("Moderation history for " + member.user.username)
.setDescription(m.embeds[0].description)
.setStatus("Danger")
.setFooter({ text: "Message timed out" })
@@ -342,18 +286,11 @@
}
}
-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")
- ],
+ embeds: [new EmojiEmbed().setEmoji("NUCLEUS.LOADING").setTitle("Downloading Data").setStatus("Danger")],
ephemeral: true,
fetchReply: true
});
@@ -415,9 +352,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Mod notes for " + member.user.username)
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
@@ -443,11 +378,7 @@
}
if (out.fields) {
const toAdd = out.fields.getTextInputValue("note") || null;
- await client.database.notes.create(
- member.guild.id,
- member.id,
- toAdd
- );
+ await client.database.notes.create(member.guild.id, member.id, toAdd);
} else {
continue;
}
@@ -460,8 +391,7 @@
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";
+ if (!member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
return true;
};
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 59c2f81..f10563e 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,9 +1,4 @@
-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";
@@ -15,16 +10,9 @@
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;
@@ -37,15 +25,10 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")),
- reason: reason
- ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
- : "*No reason provided*"
+ 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
- }>?`
+ `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addReasonButton(reason ?? "")
@@ -64,9 +47,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
@@ -96,19 +77,10 @@
dmd = false;
}
try {
- (interaction.options.getMember("user") as GuildMember).kick(
- reason ?? "No reason provided."
- );
+ (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;
+ 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",
@@ -121,35 +93,17 @@
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.*"
- ),
+ 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
- }
- )
+ humanizeDuration(new Date().getTime() - member.joinedTimestamp, {
+ round: true
+ })
),
- accountCreated: entry(
- member.user.createdAt,
- renderDelta(member.user.createdAt)
- ),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount
},
hidden: {
@@ -163,9 +117,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kick")
- .setDescription(
- "Something went wrong and the user was not kicked"
- )
+ .setDescription("Something went wrong and the user was not kicked")
.setStatus("Danger")
],
components: []
@@ -179,10 +131,7 @@
new EmojiEmbed()
.setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
.setTitle("Kick")
- .setDescription(
- "The member was kicked" +
- (failed ? ", but could not be notified" : "")
- )
+ .setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
],
components: []
@@ -205,30 +154,24 @@
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";
+ 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;
};
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index b430191..dc44e5a 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,11 +1,5 @@
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";
@@ -13,29 +7,17 @@
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)
- )
+ .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"
- )
+ .setDescription("The number of days to mute the user for | Default: 0")
.setMinValue(0)
.setMaxValue(27)
.setRequired(false)
@@ -43,9 +25,7 @@
.addIntegerOption((option) =>
option
.setName("hours")
- .setDescription(
- "The number of hours to mute the user for | Default: 0"
- )
+ .setDescription("The number of hours to mute the user for | Default: 0")
.setMinValue(0)
.setMaxValue(23)
.setRequired(false)
@@ -53,9 +33,7 @@
.addIntegerOption((option) =>
option
.setName("minutes")
- .setDescription(
- "The number of minutes to mute the user for | Default: 0"
- )
+ .setDescription("The number of minutes to mute the user for | Default: 0")
.setMinValue(0)
.setMaxValue(59)
.setRequired(false)
@@ -63,17 +41,14 @@
.addIntegerOption((option) =>
option
.setName("seconds")
- .setDescription(
- "The number of seconds to mute the user for | Default: 0"
- )
+ .setDescription("The number of seconds to mute the user for | Default: 0")
.setMinValue(0)
.setMaxValue(59)
.setRequired(false)
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const { log, NucleusColors, renderUser, entry, renderDelta } =
- client.logger;
+ const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
const user = interaction.options.getMember("user") as GuildMember;
const time = {
days: interaction.options.getInteger("days") ?? 0,
@@ -82,19 +57,12 @@
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"
- : "";
+ let serverSettingsDescription = config.moderation.mute.timeout ? "given a timeout" : "";
if (config.moderation.mute.role)
serverSettingsDescription +=
- (serverSettingsDescription ? " and " : "") +
- `given the <@&${config.moderation.mute.role}> role`;
+ (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: [
@@ -106,40 +74,16 @@
],
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 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 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()
@@ -228,9 +172,7 @@
time: `${humanizeDuration(muteTime * 1000, {
round: true
})}`,
- reason: reason
- ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
- : "*No reason provided*"
+ reason: reason ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ") : "*No reason provided*"
}) +
"The user will be " +
serverSettingsDescription +
@@ -244,12 +186,7 @@
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
async () =>
- await create(
- interaction.guild,
- interaction.options.getUser("user"),
- interaction.user,
- reason
- ),
+ await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
"CONTROL.TICKET",
createAppealTicket
@@ -291,17 +228,9 @@
? ` 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
+ 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}>`
@@ -331,10 +260,7 @@
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(
@@ -354,15 +280,11 @@
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);
@@ -374,9 +296,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
- .setDescription(
- "Something went wrong and the user was not muted"
- )
+ .setDescription("Something went wrong and the user was not muted")
.setStatus("Danger")
],
components: []
@@ -384,13 +304,7 @@
if (dmd) await dm.delete();
return;
}
- await client.database.history.create(
- "mute",
- interaction.guild.id,
- member.user,
- interaction.user,
- reason
- );
+ await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
const failed = !dmd && notify;
await interaction.editReply({
embeds: [
@@ -424,14 +338,8 @@
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)
- ),
+ 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: {
@@ -457,30 +365,24 @@
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";
+ 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;
};
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index c3d6b33..cba14f4 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -9,22 +9,12 @@
builder
.setName("nick")
.setDescription("Changes a users nickname")
- .addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to change")
- .setRequired(true)
- )
+ .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)
+ 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;
@@ -37,19 +27,12 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")),
"new nickname": `${
- interaction.options.getString("name")
- ? interaction.options.getString("name")
- : "*No 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
+ `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${
+ (interaction.options.getMember("user") as GuildMember).id
}>'s nickname?`
)
.setColor("Danger")
@@ -74,23 +57,17 @@
let dm;
try {
if (notify) {
- dm = await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ 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"
+ interaction.options.getString("name") ? "changed" : "cleared"
} in ${interaction.guild.name}.` +
(interaction.options.getString("name")
- ? ` it is now: ${interaction.options.getString(
- "name"
- )}`
+ ? ` it is now: ${interaction.options.getString("name")}`
: "") +
"\n\n" +
(confirmation.components.appeal.response
@@ -119,8 +96,7 @@
before,
nickname
);
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {
type: "memberUpdate",
@@ -134,14 +110,8 @@
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
@@ -154,9 +124,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname")
- .setDescription(
- "Something went wrong and the users nickname could not be changed."
- )
+ .setDescription("Something went wrong and the users nickname could not be changed.")
.setStatus("Danger")
],
components: []
@@ -199,30 +167,24 @@
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";
+ 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;
};
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index b78c423..63a919c 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,9 +1,4 @@
-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";
@@ -24,31 +19,19 @@
.setMaxValue(100)
)
.addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to purge messages from")
- .setRequired(false)
+ 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)
+ option.setName("reason").setDescription("The reason for the purge").setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+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())
+ !["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(
+ channel.type.toString()
+ )
) {
return await interaction.reply({
embeds: [
@@ -90,32 +73,14 @@
],
components: [
new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("1")
- .setLabel("1")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("3")
- .setLabel("3")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("5")
- .setLabel("5")
- .setStyle("SECONDARY")
+ new Discord.MessageButton().setCustomId("1").setLabel("1").setStyle("SECONDARY"),
+ new Discord.MessageButton().setCustomId("3").setLabel("3").setStyle("SECONDARY"),
+ new Discord.MessageButton().setCustomId("5").setLabel("5").setStyle("SECONDARY")
]),
new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("10")
- .setLabel("10")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("25")
- .setLabel("25")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("50")
- .setLabel("50")
- .setStyle("SECONDARY")
+ new Discord.MessageButton().setCustomId("10").setLabel("10").setStyle("SECONDARY"),
+ new Discord.MessageButton().setCustomId("25").setLabel("25").setStyle("SECONDARY"),
+ new Discord.MessageButton().setCustomId("50").setLabel("50").setStyle("SECONDARY")
]),
new Discord.MessageActionRow().addComponents([
new Discord.MessageButton()
@@ -144,17 +109,12 @@
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));
}
@@ -181,8 +141,7 @@
deleted.length
);
}
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -193,18 +152,9 @@
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: {
@@ -214,9 +164,7 @@
log(data);
let out = "";
deleted.reverse().forEach((message) => {
- out += `${message.author.username}#${
- message.author.discriminator
- } (${message.author.id}) [${new Date(
+ out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(
message.createdTimestamp
).toISOString()}]\n`;
const lines = message.content.split("\n");
@@ -304,29 +252,19 @@
let messages;
try {
if (!user) {
- const toDelete = await (
- interaction.channel as TextChannel
- ).messages.fetch({
+ const toDelete = await (interaction.channel as TextChannel).messages.fetch({
limit: interaction.options.getInteger("amount")
});
- messages = await (channel as TextChannel).bulkDelete(
- toDelete,
- true
- );
+ messages = await (channel as TextChannel).bulkDelete(toDelete, true);
} else {
const toDelete = (
await (
- await (
- interaction.channel as TextChannel
- ).messages.fetch({
+ 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
- );
+ messages = await (channel as TextChannel).bulkDelete(toDelete, true);
}
} catch (e) {
await interaction.editReply({
@@ -334,9 +272,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
- .setDescription(
- "Something went wrong and no messages were deleted"
- )
+ .setDescription("Something went wrong and no messages were deleted")
.setStatus("Danger")
],
components: []
@@ -353,8 +289,7 @@
messages.size
);
}
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -365,18 +300,9 @@
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: {
@@ -386,9 +312,7 @@
log(data);
let out = "";
messages.reverse().forEach((message) => {
- out += `${message.author.username}#${
- message.author.discriminator
- } (${message.author.id}) [${new Date(
+ out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(
message.createdTimestamp
).toISOString()}]\n`;
const lines = message.content.split("\n");
@@ -472,13 +396,11 @@
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;
};
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 1a06db1..5565534 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -34,10 +34,7 @@
const callback = async (interaction: CommandInteraction): Promise<void> => {
let time = parseInt(interaction.options.getString("time") ?? "0");
- if (
- time === 0 &&
- (interaction.channel as TextChannel).rateLimitPerUser === 0
- ) {
+ if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) {
time = 10;
}
const confirmation = await new confirmationMessage(interaction)
@@ -45,9 +42,7 @@
.setTitle("Slowmode")
.setDescription(
keyValueList({
- time: time
- ? humanizeDuration(time * 1000, { round: true })
- : "No delay"
+ time: time ? humanizeDuration(time * 1000, { round: true }) : "No delay"
}) + "Are you sure you want to set the slowmode in this channel?"
)
.setColor("Danger")
@@ -62,9 +57,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setTitle("Slowmode")
- .setDescription(
- "Something went wrong while setting the slowmode"
- )
+ .setDescription("Something went wrong while setting the slowmode")
.setStatus("Danger")
],
components: []
@@ -100,8 +93,7 @@
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;
};
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index f3c475e..57a70dc 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,9 +1,4 @@
-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";
@@ -15,12 +10,7 @@
builder
.setName("softban")
.setDescription("Kicks a user and deletes their messages")
- .addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to softban")
- .setRequired(true)
- )
+ .addUserOption((option) => option.setName("user").setDescription("The user to softban").setRequired(true))
.addIntegerOption((option) =>
option
.setName("delete")
@@ -30,9 +20,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;
@@ -45,21 +33,14 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")),
- reason: reason
- ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
- : "*No reason provided*"
+ 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,
+ 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
- }>?`
+ `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
@@ -86,9 +67,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -130,30 +109,20 @@
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
- .setDescription(
- "Something went wrong and the user was not softbanned"
- )
+ .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
- );
+ 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" : "")
- )
+ .setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
],
components: []
@@ -176,30 +145,24 @@
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";
+ 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;
};
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 06fe647..9ba10e1 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -10,34 +10,21 @@
.setName("unban")
.setDescription("Unbans a user")
.addStringOption((option) =>
- option
- .setName("user")
- .setDescription("The user to unban (Username or ID)")
- .setRequired(true)
+ 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()
- );
+ 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}\``
- )
+ .setDescription(`Could not find any user called \`${user}\``)
.setEmoji("PUNISH.UNBAN.RED")
.setStatus("Danger")
],
@@ -58,19 +45,10 @@
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await interaction.guild.members.unban(
- resolved.user as User,
- "Unban"
- );
+ 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 client.database.history.create("unban", interaction.guild.id, member, interaction.user);
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {
type: "memberUnban",
@@ -83,18 +61,9 @@
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
@@ -107,9 +76,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.UNBAN.RED")
.setTitle("Unban")
- .setDescription(
- "Something went wrong and the user was not unbanned"
- )
+ .setDescription("Something went wrong and the user was not unbanned")
.setStatus("Danger")
],
components: []
@@ -143,13 +110,11 @@
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;
};
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index f625461..40a2093 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -9,18 +9,10 @@
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;
@@ -35,10 +27,7 @@
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
- }>?`
+ `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addReasonButton(reason ?? "")
@@ -55,18 +44,14 @@
let dm;
try {
if (notify) {
- dm = await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ 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.")
+ (reason ? ` for:\n> ${reason}` : " with no reason provided.")
)
.setStatus("Success")
]
@@ -85,9 +70,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Unmute")
- .setDescription(
- "Something went wrong and the user was not unmuted"
- )
+ .setDescription("Something went wrong and the user was not unmuted")
.setStatus("Danger")
],
components: []
@@ -114,14 +97,8 @@
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
@@ -134,10 +111,7 @@
new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle("Unmute")
- .setDescription(
- "The member was unmuted" +
- (failed ? ", but could not be notified" : "")
- )
+ .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
],
components: []
@@ -160,28 +134,22 @@
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";
+ 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;
};
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index f0b2047..577192f 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -15,19 +15,13 @@
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);
+ if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel);
});
channels = [channels];
channels = channels.concat(
@@ -38,11 +32,7 @@
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) && 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;
@@ -54,9 +44,7 @@
if (!b[0].parent) return 1;
return a[0].parent.position - b[0].parent.position;
});
- const member = interaction.options.getMember(
- "member"
- ) as Discord.GuildMember;
+ const member = interaction.options.getMember("member") as Discord.GuildMember;
m = await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -76,48 +64,26 @@
.setTitle("Viewing as " + member.displayName)
.setStatus("Success")
.setDescription(
- `**${
- channels[page][0].parent
- ? channels[page][0].parent.name
- : "Uncategorised"
- }**` +
+ `**${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 (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
- ) {
+ if ("threads" in c && c.threads.cache.size > 0) {
return (
c.threads.cache
.map(
(t) =>
` ${
- getEmojiByName(
- "ICONS.CHANNEL.THREAD_PIPE"
- ) +
+ getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") +
" " +
- getEmojiByName(
- "ICONS.CHANNEL.THREAD_CHANNEL"
- )
- } ${
- t.name
- }`
+ getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")
+ } ${t.name}`
)
.join("\n") + "\n"
);
@@ -136,9 +102,7 @@
new MessageSelectMenu()
.setOptions(
channels.map((c, index) => ({
- label: c[0].parent
- ? c[0].parent.name
- : "Uncategorised",
+ label: c[0].parent ? c[0].parent.name : "Uncategorised",
value: index.toString(),
default: page === index
}))
@@ -195,8 +159,7 @@
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";
+ if (!member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
return true;
};
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 91c876e..5e321d0 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,33 +1,18 @@
-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;
@@ -41,15 +26,10 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")),
- reason: reason
- ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
- : "*No reason provided*"
+ 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
- }>?`
+ `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
@@ -57,12 +37,7 @@
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
async () =>
- await create(
- interaction.guild,
- interaction.options.getUser("user"),
- interaction.user,
- reason
- ),
+ await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
"CONTROL.TICKET",
createAppealTicket
@@ -91,12 +66,8 @@
let dmd = false;
try {
if (notify) {
- const config = await client.database.guilds.read(
- interaction.guild.id
- );
- await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ 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")
@@ -145,17 +116,10 @@
},
list: {
user: entry(
- (interaction.options.getMember("user") as GuildMember).user
- .id,
- renderUser(
- (interaction.options.getMember("user") as GuildMember)
- .user
- )
+ (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)
- ),
+ warnedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
reason: reason ? `\n> ${reason}` : "No reason provided"
},
hidden: {
@@ -188,9 +152,7 @@
components: []
});
} else {
- const canSeeChannel = (
- interaction.options.getMember("user") as GuildMember
- )
+ const canSeeChannel = (interaction.options.getMember("user") as GuildMember)
.permissionsIn(interaction.channel as Discord.TextChannel)
.has("VIEW_CHANNEL");
const m = (await interaction.editReply({
@@ -198,17 +160,12 @@
new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
- .setDescription(
- "The user's DMs are not open\n\nWhat would you like to do?"
- )
+ .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")
- .setLabel("Ignore and log")
- .setStyle("SECONDARY"),
+ new Discord.MessageButton().setCustomId("log").setLabel("Ignore and log").setStyle("SECONDARY"),
new Discord.MessageButton()
.setCustomId("here")
.setLabel("Warn here")
@@ -245,24 +202,12 @@
new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
- .setDescription(
- "You have been warned" +
- (reason ? ` for:\n> ${reason}` : ".")
- )
+ .setDescription("You have been warned" + (reason ? ` for:\n> ${reason}` : "."))
.setStatus("Danger")
],
- content: `<@!${
- (interaction.options.getMember("user") as GuildMember)
- .id
- }>`,
+ content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
allowedMentions: {
- users: [
- (
- interaction.options.getMember(
- "user"
- ) as GuildMember
- ).id
- ]
+ users: [(interaction.options.getMember("user") as GuildMember).id]
}
});
return await interaction.editReply({
@@ -316,9 +261,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle("Warn")
- .setDescription(
- `A ticket was created in <#${ticketChannel}>`
- )
+ .setDescription(`A ticket was created in <#${ticketChannel}>`)
.setStatus("Success")
],
components: []
@@ -343,8 +286,7 @@
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";
+ 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
@@ -352,11 +294,9 @@
// 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;
};
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index b9df446..ffc441a 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -2,9 +2,7 @@
import guide from "../../reflex/guide.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("guide")
- .setDescription("Shows the welcome guide for the bot");
+ builder.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 8ae8c1a..341f7d2 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -1,8 +1,4 @@
-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";
@@ -15,9 +11,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Invite")
- .setDescription(
- "You can invite Nucleus to your server by clicking the button below"
- )
+ .setDescription("You can invite Nucleus to your server by clicking the button below")
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
],
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 105cda5..59b6393 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -20,9 +20,7 @@
.setDescription(
`**Ping:** \`${ping}ms\`\n` +
`**To Discord:** \`${client.ws.ping}ms\`\n` +
- `**From Expected:** \`±${Math.abs(
- ping / 2 - client.ws.ping
- )}ms\``
+ `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
)
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setStatus("Danger")
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 83ba327..9bbc36e 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -3,9 +3,7 @@
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("premium")
- .setDescription("Information about Nucleus Premium");
+ builder.setName("premium").setDescription("Information about Nucleus Premium");
const callback = async (interaction: CommandInteraction): Promise<void> => {
interaction.reply({
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index 68eeaa9..a67cd36 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -11,10 +11,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Stats")
- .setDescription(
- `**Servers:** ${client.guilds.cache.size}\n` +
- `**Ping:** \`${client.ws.ping * 2}ms\``
- )
+ .setDescription(`**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``)
.setStatus("Success")
.setEmoji("GUILD.GRAPHS")
],
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 0f40501..bdd55af 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -10,10 +10,7 @@
.setName("suggest")
.setDescription("Sends a suggestion to the developers")
.addStringOption((option) =>
- option
- .setName("suggestion")
- .setDescription("The suggestion to send")
- .setRequired(true)
+ option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
@@ -31,18 +28,12 @@
.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}`
+ `**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`
)
.setStatus("Danger")
.setEmoji("NUCLEUS.LOGO")
@@ -72,10 +63,7 @@
}
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 3c36ea1..7903666 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,9 +1,5 @@
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";
@@ -14,9 +10,7 @@
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;
@@ -91,22 +85,16 @@
.setStatus("Danger")
)
.setTitle("Link scanning and Transcripts")
- .setDescription(
- "Regarding Facebook and AMP filter types, and ticket transcripts"
- )
+ .setDescription("Regarding Facebook and AMP filter types, and ticket transcripts")
.setPageId(2)
].concat(
- (interaction.member as Discord.GuildMember).permissions.has(
- "ADMINISTRATOR"
- )
+ (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"
- )
+ .setDescription("Below are buttons for controlling this servers privacy settings")
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
)
@@ -178,9 +166,7 @@
])
]);
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));
em.setFooter({ text: nextFooter ?? "" });
await interaction.editReply({
embeds: [em],
@@ -229,20 +215,14 @@
}
} else {
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));
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.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
em.setFooter({ text: "Message timed out" });
await interaction.editReply({
embeds: [em],
@@ -250,10 +230,7 @@
});
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index 2557b4b..3b3eb79 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -11,16 +11,10 @@
.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)
+ 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)
+ option.setName("role").setDescription("The role to give or remove").setRequired(true)
)
.addStringOption((option) =>
option
@@ -33,9 +27,7 @@
])
);
-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
@@ -48,9 +40,7 @@
role: renderRole(interaction.options.getRole("role"))
}) +
`\nAre you sure you want to ${
- action === "give"
- ? "give the role to"
- : "remove the role from"
+ action === "give" ? "give the role to" : "remove the role from"
} ${interaction.options.getUser("user")}?`
)
.setColor("Danger")
@@ -70,9 +60,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Role")
- .setDescription(
- "Something went wrong and the role could not be added"
- )
+ .setDescription("Something went wrong and the role could not be added")
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
],
@@ -83,11 +71,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Role")
- .setDescription(
- `The role has been ${
- action === "give" ? "given" : "removed"
- } successfully`
- )
+ .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
],
@@ -107,23 +91,17 @@
}
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
+ 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;
};
diff --git a/src/commands/rolemenu.ts b/src/commands/rolemenu.ts
index 8566966..dd3cb34 100644
--- a/src/commands/rolemenu.ts
+++ b/src/commands/rolemenu.ts
@@ -11,10 +11,7 @@
await roleMenu(interaction);
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 0a1cc6f..4465be5 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -3,9 +3,7 @@
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) =>
@@ -31,18 +29,9 @@
(guild.emojis.cache.size > 1
? `\n> ${guild.emojis.cache
.first(10)
- .map(
- (emoji) =>
- `<${emoji.animated ? "a" : ""}:${
- emoji.name
- }:${emoji.id}>`
- )
+ .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
.join(" ")}` +
- (guild.emojis.cache.size > 10
- ? ` and ${
- guild.emojis.cache.size - 10
- } more`
- : "")
+ (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
: ""),
icon: `[Discord](${guild.iconURL()})`,
"2 factor authentication": `${
@@ -50,19 +39,11 @@
? `${getEmojiByName("CONTROL.CROSS")} No`
: `${getEmojiByName("CONTROL.TICK")} Yes`
}`,
- "verification level": `${toCapitals(
- guild.verificationLevel
- )}`,
+ "verification level": `${toCapitals(guild.verificationLevel)}`,
"explicit content filter": `${toCapitals(
- guild.explicitContentFilter
- .toString()
- .replace(/_/, " ")
+ guild.explicitContentFilter.toString().replace(/_/, " ")
)}`,
- "nitro boost level": `${
- guild.premiumTier !== "NONE"
- ? guild.premiumTier.toString()[-1]
- : "0"
- }`,
+ "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
channels: `${guild.channels.cache.size}`,
roles: `${guild.roles.cache.size}`,
members: `${guild.memberCount}`
@@ -74,10 +55,7 @@
});
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 13cfa89..19a13e3 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,10 +1,5 @@
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";
@@ -17,18 +12,10 @@
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> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -75,9 +62,7 @@
.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*")
+ (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
)
],
components: [
@@ -117,35 +102,16 @@
]),
new MessageActionRow().addComponents([
new MessageButton()
- .setLabel(
- clicked === "clearMuteRole"
- ? "Click again to confirm"
- : "Clear mute role"
- )
+ .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"
- )
- )
+ .setLabel("Mute timeout " + (moderation.mute.timeout ? "Enabled" : "Disabled"))
+ .setStyle(moderation.mute.timeout ? "SUCCESS" : "DANGER")
+ .setEmoji(getEmojiByName("CONTROL." + (moderation.mute.timeout ? "TICK" : "CROSS"), "id"))
])
]
});
@@ -193,9 +159,7 @@
new MessageActionRow<TextInputComponent>().addComponents(
new TextInputComponent()
.setCustomId("url")
- .setLabel(
- "URL - Type {id} to insert the user's ID"
- )
+ .setLabel("URL - Type {id} to insert the user's ID")
.setMaxLength(2000)
.setRequired(false)
.setStyle("SHORT")
@@ -207,9 +171,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Moderation Links")
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
@@ -235,14 +197,9 @@
}
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]: {
@@ -258,10 +215,7 @@
}
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index ea8aa51..8e72651 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,10 +1,6 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types/v9";
-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";
@@ -24,9 +20,7 @@
.setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const m = (await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -42,9 +36,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Attachment Log Channel")
- .setDescription(
- "The channel you provided is not a valid channel"
- )
+ .setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
@@ -55,9 +47,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Attachment Log Channel")
- .setDescription(
- "You must choose a channel in this server"
- )
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -79,8 +69,7 @@
await client.database.guilds.write(interaction.guild.id, {
"logging.attachments.channel": channel.id
});
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "attachmentChannelUpdate",
@@ -91,14 +80,8 @@
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: {
@@ -111,9 +94,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Attachment Log Channel")
- .setDescription(
- "Something went wrong and the attachment log channel could not be set"
- )
+ .setDescription("Something went wrong and the attachment log channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
],
@@ -145,9 +126,7 @@
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
- )
+ (client.database.premium.hasPremium(interaction.guild.id)
? ""
: "\n\nThis server does not have premium, so this feature is disabled")
)
@@ -158,15 +137,8 @@
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("clear")
- .setLabel(
- clicks ? "Click again to confirm" : "Reset channel"
- )
- .setEmoji(
- getEmojiByName(
- clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
- "id"
- )
- )
+ .setLabel(clicks ? "Click again to confirm" : "Reset channel")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setDisabled(!channel)
])
@@ -183,9 +155,7 @@
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 {
@@ -218,10 +188,7 @@
});
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index fd64424..21437b2 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,10 +1,6 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types/v9";
-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";
@@ -23,9 +19,7 @@
.addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const m = (await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -41,9 +35,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Log Channel")
- .setDescription(
- "The channel you provided is not a valid channel"
- )
+ .setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
@@ -54,9 +46,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Log Channel")
- .setDescription(
- "You must choose a channel in this server"
- )
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -65,9 +55,7 @@
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);
@@ -77,8 +65,7 @@
await client.database.guilds.write(interaction.guild.id, {
"logging.logs.channel": channel.id
});
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "logChannelUpdate",
@@ -89,14 +76,8 @@
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: {
@@ -110,9 +91,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Log Channel")
- .setDescription(
- "Something went wrong and the log channel could not be set"
- )
+ .setDescription("Something went wrong and the log channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
],
@@ -152,15 +131,8 @@
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("clear")
- .setLabel(
- clicks ? "Click again to confirm" : "Reset channel"
- )
- .setEmoji(
- getEmojiByName(
- clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
- "id"
- )
- )
+ .setLabel(clicks ? "Click again to confirm" : "Reset channel")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setDisabled(!channel)
])
@@ -177,9 +149,7 @@
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 {
@@ -212,10 +182,7 @@
});
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index a1edcaf..a2dcc63 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,10 +1,5 @@
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";
@@ -35,9 +30,7 @@
};
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("events")
- .setDescription("Sets what events should be logged");
+ builder.setName("events").setDescription("Sets what events should be logged");
const callback = async (interaction: CommandInteraction): Promise<void> => {
await interaction.reply({
@@ -75,14 +68,8 @@
)
]),
new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Select all")
- .setStyle("PRIMARY")
- .setCustomId("all"),
- new MessageButton()
- .setLabel("Select none")
- .setStyle("DANGER")
- .setCustomId("none")
+ new MessageButton().setLabel("Select all").setStyle("PRIMARY").setCustomId("all"),
+ new MessageButton().setLabel("Select none").setStyle("DANGER").setCustomId("none")
])
]
});
@@ -95,9 +82,7 @@
i.deferUpdate();
if (i.customId === "logs") {
const selected = i.values;
- const newLogs = toHexInteger(
- selected.map((e) => Object.keys(logs)[parseInt(e)])
- );
+ const newLogs = toHexInteger(selected.map((e) => Object.keys(logs)[parseInt(e)]));
await client.database.guilds.write(interaction.guild.id, {
"logging.logs.toLog": newLogs
});
@@ -129,10 +114,7 @@
return;
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index a0df97c..8450bbb 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,10 +1,6 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types/v9";
-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";
@@ -20,16 +16,12 @@
.addChannelOption((option) =>
option
.setName("channel")
- .setDescription(
- "The channel to set the staff notifications channel to"
- )
+ .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,
@@ -46,9 +38,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Staff Notifications Channel")
- .setDescription(
- "The channel you provided is not a valid channel"
- )
+ .setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
@@ -59,9 +49,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Staff Notifications Channel")
- .setDescription(
- "You must choose a channel in this server"
- )
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -83,8 +71,7 @@
await client.database.guilds.write(interaction.guild.id, {
"logging.staff.channel": channel.id
});
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "staffChannelUpdate",
@@ -95,14 +82,8 @@
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: {
@@ -115,9 +96,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Staff Notifications Channel")
- .setDescription(
- "Something went wrong and the staff notifications channel could not be set"
- )
+ .setDescription("Something went wrong and the staff notifications channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
],
@@ -157,15 +136,8 @@
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("clear")
- .setLabel(
- clicks ? "Click again to confirm" : "Reset channel"
- )
- .setEmoji(
- getEmojiByName(
- clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
- "id"
- )
- )
+ .setLabel(clicks ? "Click again to confirm" : "Reset channel")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setDisabled(!channel)
])
@@ -182,9 +154,7 @@
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 {
@@ -217,10 +187,7 @@
});
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index beb2f35..93fe70d 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -6,21 +6,14 @@
builder
.setName("rolemenu")
.setDescription("rolemenu") // TODO
- .addRoleOption((option) =>
- option
- .setName("role")
- .setDescription("The role to give after verifying")
- ); // FIXME FOR FUCK SAKE
+ .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 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";
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 507e506..08bf6f8 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,10 +1,5 @@
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";
@@ -17,24 +12,16 @@
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")
- )
+ .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}"
- )
+ .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,
@@ -50,9 +37,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Stats Channel")
- .setDescription(
- "You can only have 25 stats channels in a server"
- )
+ .setDescription("You can only have 25 stats channels in a server")
.setStatus("Danger")
]
});
@@ -65,9 +50,7 @@
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Stats Channel")
- .setDescription(
- "The channel you provided is not a valid channel"
- )
+ .setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
@@ -78,9 +61,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Stats Channel")
- .setDescription(
- "You must choose a channel in this server"
- )
+ .setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -100,9 +81,7 @@
.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(
+ `Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(
/^ +| $/g,
""
)}*`
@@ -118,8 +97,7 @@
await client.database.guilds.write(interaction.guild.id, {
[`stats.${channel.id}`]: { name: name, enabled: true }
});
- const { log, NucleusColors, entry, renderUser, renderChannel } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "statsChannelUpdate",
@@ -130,14 +108,8 @@
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"),
@@ -155,9 +127,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Stats Channel")
- .setDescription(
- "Something went wrong and the stats channel could not be set"
- )
+ .setDescription("Something went wrong and the stats channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
],
@@ -200,14 +170,10 @@
Object.keys(stats).length
? [
selectMenu
- .setPlaceholder(
- "Select a stats channel to remove, stopping it updating"
- )
+ .setPlaceholder("Select a stats channel to remove, stopping it updating")
.addOptions(
Object.keys(stats).map((key) => ({
- label: interaction.guild.channels.cache.get(
- key
- ).name,
+ label: interaction.guild.channels.cache.get(key).name,
value: key,
description: `${stats[key].name}`
}))
@@ -215,9 +181,7 @@
]
: [
selectMenu
- .setPlaceholder(
- "The server has no stats channels"
- )
+ .setPlaceholder("The server has no stats channels")
.setDisabled(true)
.setOptions([
{
@@ -252,10 +216,7 @@
});
};
-const check = (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+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";
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 206e157..3c6515d 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -15,17 +15,10 @@
SelectMenuInteraction,
TextInputComponent
} from "discord.js";
-import {
- SelectMenuOption,
- SlashCommandSubcommandBuilder
-} from "@discordjs/builders";
+import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v9";
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";
@@ -33,9 +26,7 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("tickets")
- .setDescription(
- "Shows settings for tickets | Use no arguments to manage custom types"
- )
+ .setDescription("Shows settings for tickets | Use no arguments to manage custom types")
.addStringOption((option) =>
option
.setName("enabled")
@@ -56,9 +47,7 @@
.addNumberOption((option) =>
option
.setName("maxticketsperuser")
- .setDescription(
- "The maximum amount of tickets a user can create | Default: 5"
- )
+ .setDescription("The maximum amount of tickets a user can create | Default: 5")
.setRequired(false)
.setMinValue(1)
)
@@ -71,9 +60,7 @@
.setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
let m = (await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -85,28 +72,19 @@
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"
- )
+ .setDescription("The channel you provided is not a valid category")
.setStatus("Danger")
]
});
@@ -117,9 +95,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tickets > Category")
- .setDescription(
- "You must choose a category in this server"
- )
+ .setDescription("You must choose a category in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -131,9 +107,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tickets > Max Tickets")
- .setDescription(
- "You must choose a number greater than 0"
- )
+ .setDescription("You must choose a number greater than 0")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
@@ -142,18 +116,14 @@
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"
- )
+ .setDescription("The role you provided is not a valid role")
.setStatus("Danger")
]
});
@@ -164,9 +134,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tickets > Support Ping")
- .setDescription(
- "You must choose a role in this server"
- )
+ .setDescription("You must choose a role in this server")
.setStatus("Danger")
.setEmoji("GUILD.ROLE.DELETE")
]
@@ -177,15 +145,9 @@
.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.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
@@ -201,27 +163,18 @@
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"
- )
+ .setDescription("Something went wrong and the staff notifications channel could not be set")
.setStatus("Danger")
.setEmoji("GUILD.TICKET.DELETE")
],
@@ -243,8 +196,7 @@
}
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
+ (value: string, index: number, array: string[]) => array.indexOf(value) === index
);
let lastClicked = "";
let embed: EmojiEmbed;
@@ -261,34 +213,18 @@
embed = new EmojiEmbed()
.setTitle("Tickets")
.setDescription(
- `${
- data.enabled ? "" : getEmojiByName("TICKETS.REPORT")
- } **Enabled:** ${
- data.enabled
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`
+ `${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 ? "" : 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")} `
- : "") +
+ `**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*`
+ `${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN");
@@ -297,43 +233,24 @@
components: [
new MessageActionRow().addComponents([
new MessageButton()
- .setLabel(
- "Tickets " + (data.enabled ? "enabled" : "disabled")
- )
- .setEmoji(
- getEmojiByName(
- "CONTROL." + (data.enabled ? "TICK" : "CROSS"),
- "id"
- )
- )
+ .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"
- )
+ .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"
- )
+ .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"
- )
+ .setLabel(lastClicked === "sup" ? "Click again to confirm" : "Clear support ping")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setCustomId("clearSupportPing")
@@ -360,42 +277,25 @@
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",
@@ -403,13 +303,11 @@
},
{
label: "Issues, questions or feedback?",
- description:
- "Click below to open a ticket and get help from our staff team"
+ 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"
+ description: "Click the button below to speak to us privately"
}
];
while (true) {
@@ -418,9 +316,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Ticket Button")
- .setDescription(
- "Select a message template to send in this channel"
- )
+ .setDescription("Select a message template to send in this channel")
.setFooter({
text: enabled
? ""
@@ -462,10 +358,7 @@
.setLabel("Back")
.setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
.setStyle("DANGER"),
- new MessageButton()
- .setCustomId("blank")
- .setLabel("Empty")
- .setStyle("SECONDARY"),
+ new MessageButton().setCustomId("blank").setLabel("Empty").setStyle("SECONDARY"),
new MessageButton()
.setCustomId("custom")
.setLabel("Custom")
@@ -480,29 +373,14 @@
} catch (e) {
break;
}
- if (
- (i.component as MessageActionRowComponent).customId ===
- "template"
- ) {
+ 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
- )
+ .setTitle(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
.setDescription(
- ticketMessages[
- parseInt(
- (i as SelectMenuInteraction)
- .values[0]
- )
- ].description
+ ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].description
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
@@ -511,41 +389,28 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Create Ticket")
- .setEmoji(
- getEmojiByName("CONTROL.TICK", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
.setStyle("SUCCESS")
.setCustomId("createticket")
])
]
});
break;
- } else if (
- (i.component as MessageActionRowComponent).customId ===
- "blank"
- ) {
+ } 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"
- )
- )
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("SUCCESS")
.setCustomId("createticket")
])
]
});
break;
- } else if (
- (i.component as MessageActionRowComponent).customId ===
- "custom"
- ) {
+ } else if ((i.component as MessageActionRowComponent).customId === "custom") {
await i.showModal(
new Discord.Modal()
.setCustomId("modal")
@@ -573,9 +438,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Ticket Button")
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
@@ -583,9 +446,7 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Back")
- .setEmoji(
- getEmojiByName("CONTROL.LEFT", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
.setStyle("PRIMARY")
.setCustomId("back")
])
@@ -603,8 +464,7 @@
}
if (out.fields) {
const title = out.fields.getTextInputValue("title");
- const description =
- out.fields.getTextInputValue("description");
+ const description = out.fields.getTextInputValue("description");
await interaction.channel.send({
embeds: [
new EmojiEmbed()
@@ -617,12 +477,7 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Create Ticket")
- .setEmoji(
- getEmojiByName(
- "TICKETS.SUGGESTION",
- "id"
- )
- )
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
.setStyle("SUCCESS")
.setCustomId("createticket")
])
@@ -634,17 +489,12 @@
}
}
}
- } else if (
- (i.component as MessageActionRowComponent).customId === "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;
@@ -656,11 +506,7 @@
});
};
-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;
@@ -671,11 +517,7 @@
.setDescription(
"**Custom types enabled**\n\n" +
"**Types in use:**\n" +
- (customTypes !== null
- ? customTypes
- .map((t) => `> ${t}`)
- .join("\n")
- : "*None set*") +
+ (customTypes !== null ? customTypes.map((t) => `> ${t}`).join("\n") : "*None set*") +
"\n\n" +
(customTypes === null
? `${getEmojiByName(
@@ -712,14 +554,10 @@
.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")
@@ -735,12 +573,7 @@
new SelectMenuOption({
label: capitalize(type),
value: type,
- emoji: client.emojis.cache.get(
- getEmojiByName(
- `TICKETS.${type.toUpperCase()}`,
- "id"
- )
- ),
+ emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")),
default: inUse.includes(type)
})
);
@@ -761,12 +594,7 @@
"**Default types enabled**\n\n" +
"**Types in use:**\n" +
inUse
- .map(
- (t) =>
- `> ${getEmojiByName(
- "TICKETS." + t.toUpperCase()
- )} ${capitalize(t)}`
- )
+ .map((t) => `> ${getEmojiByName("TICKETS." + t.toUpperCase())} ${capitalize(t)}`)
.join("\n")
)
.setStatus("Success")
@@ -835,9 +663,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tickets > Types")
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
@@ -868,11 +694,7 @@
}
toAdd = toAdd.substring(0, 80);
try {
- await client.database.guilds.append(
- interaction.guild.id,
- "tickets.customTypes",
- toAdd
- );
+ await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd);
} catch {
continue;
}
@@ -885,19 +707,11 @@
}
} 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();
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index e0af802..614ecb9 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -24,15 +24,10 @@
.setName("verify")
.setDescription("Manage the role given after typing /verify")
.addRoleOption((option) =>
- option
- .setName("role")
- .setDescription("The role to give after verifying")
- .setRequired(false)
+ option.setName("role").setDescription("The role to give after verifying").setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const m = (await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -48,9 +43,7 @@
new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Verify Role")
- .setDescription(
- "The role you provided is not a valid role"
- )
+ .setDescription("The role you provided is not a valid role")
.setStatus("Danger")
]
});
@@ -70,9 +63,7 @@
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);
@@ -83,8 +74,7 @@
"verify.role": role.id,
"verify.enabled": true
});
- const { log, NucleusColors, entry, renderUser, renderRole } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderRole } = client.logger;
const data = {
meta: {
type: "verifyRoleChanged",
@@ -95,14 +85,8 @@
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: {
@@ -116,9 +100,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify Role")
- .setDescription(
- "Something went wrong while setting the verify role"
- )
+ .setDescription("Something went wrong while setting the verify role")
.setStatus("Danger")
.setEmoji("GUILD.ROLES.DELETE")
],
@@ -147,9 +129,7 @@
new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(
- role
- ? `Your verify role is currently set to <@&${role}>`
- : "You have not set a verify role"
+ role ? `Your verify role is currently set to <@&${role}>` : "You have not set a verify role"
)
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
@@ -158,15 +138,8 @@
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("clear")
- .setLabel(
- clicks ? "Click again to confirm" : "Reset role"
- )
- .setEmoji(
- getEmojiByName(
- clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
- "id"
- )
- )
+ .setLabel(clicks ? "Click again to confirm" : "Reset role")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
.setStyle("DANGER")
.setDisabled(!role),
new MessageButton()
@@ -188,15 +161,10 @@
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",
@@ -204,8 +172,7 @@
},
{
label: "Get verified",
- description:
- "To get access to the rest of the server, click the button below"
+ description: "To get access to the rest of the server, click the button below"
},
{
label: "Ready to verify?",
@@ -217,13 +184,9 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify Button")
- .setDescription(
- "Select a message template to send in this channel"
- )
+ .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."
+ text: role ? "" : "You do no have a verify role set so the button will not work."
})
.setStatus(role ? "Success" : "Warning")
.setEmoji("GUILD.ROLES.CREATE")
@@ -261,10 +224,7 @@
.setLabel("Back")
.setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
.setStyle("DANGER"),
- new MessageButton()
- .setCustomId("blank")
- .setLabel("Empty")
- .setStyle("SECONDARY"),
+ new MessageButton().setCustomId("blank").setLabel("Empty").setStyle("SECONDARY"),
new MessageButton()
.setCustomId("custom")
.setLabel("Custom")
@@ -279,29 +239,14 @@
} catch (e) {
break;
}
- if (
- (i.component as MessageActionRowComponent).customId ===
- "template"
- ) {
+ 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
- )
+ .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
.setDescription(
- verifyMessages[
- parseInt(
- (i as SelectMenuInteraction)
- .values[0]
- )
- ].description
+ verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description
)
.setStatus("Success")
.setEmoji("CONTROL.BLOCKTICK")
@@ -310,38 +255,28 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Verify")
- .setEmoji(
- getEmojiByName("CONTROL.TICK", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])
]
});
break;
- } else if (
- (i.component as MessageActionRowComponent).customId ===
- "blank"
- ) {
+ } 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")
- )
+ .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])
]
});
break;
- } else if (
- (i.component as MessageActionRowComponent).customId ===
- "custom"
- ) {
+ } else if ((i.component as MessageActionRowComponent).customId === "custom") {
await i.showModal(
new Discord.Modal()
.setCustomId("modal")
@@ -369,9 +304,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify Button")
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
],
@@ -379,9 +312,7 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Back")
- .setEmoji(
- getEmojiByName("CONTROL.LEFT", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
.setStyle("PRIMARY")
.setCustomId("back")
])
@@ -399,8 +330,7 @@
}
if (out.fields) {
const title = out.fields.getTextInputValue("title");
- const description =
- out.fields.getTextInputValue("description");
+ const description = out.fields.getTextInputValue("description");
await interaction.channel.send({
embeds: [
new EmojiEmbed()
@@ -413,9 +343,7 @@
new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Verify")
- .setEmoji(
- getEmojiByName("CONTROL.TICK", "id")
- )
+ .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
.setStyle("SUCCESS")
.setCustomId("verifybutton")
])
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index d2843c5..d1c2011 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -19,39 +19,28 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("welcome")
- .setDescription(
- "Messages and roles sent or given when someone joins the server"
- )
+ .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"
- )
+ .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")
+ 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")
+ 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"
- )
+ .setDescription("The channel the welcome message should be sent to")
.addChannelTypes([ChannelType.GuildText, ChannelType.GuildNews])
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } =
- client.logger;
+ const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
await interaction.reply({
embeds: LoadingEmbed,
fetchReply: true,
@@ -75,9 +64,7 @@
new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Welcome Events")
- .setDescription(
- "The role you provided is not a valid role"
- )
+ .setDescription("The role you provided is not a valid role")
.setStatus("Danger")
]
});
@@ -91,9 +78,7 @@
new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Welcome Events")
- .setDescription(
- "The channel you provided is not a valid channel"
- )
+ .setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
@@ -118,24 +103,14 @@
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 (channel) list.channel = entry(channel.id, renderChannel(channel.id));
if (message) list.message = entry(message, `\`${message}\``);
const data = {
meta: {
@@ -158,9 +133,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Welcome Events")
- .setDescription(
- "Something went wrong while updating welcome settings"
- )
+ .setDescription("Something went wrong while updating welcome settings")
.setStatus("Danger")
.setEmoji("GUILD.ROLES.DELETE")
],
@@ -188,38 +161,22 @@
new EmojiEmbed()
.setTitle("Welcome Events")
.setDescription(
- `**Message:** ${
- config.welcome.message
- ? `\n> ${config.welcome.message}`
- : "*None set*"
- }\n` +
+ `**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` +
`**Role:** ${
config.welcome.role
- ? renderRole(
- await interaction.guild.roles.fetch(
- 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
- )
- )
+ ? 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
- )
- )
+ : renderChannel(await interaction.guild.channels.fetch(config.welcome.channel))
: "*None set*"
}`
)
@@ -229,41 +186,25 @@
components: [
new MessageActionRow().addComponents([
new MessageButton()
- .setLabel(
- lastClicked == "clear-message"
- ? "Click again to confirm"
- : "Clear Message"
- )
+ .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"
- )
+ .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"
- )
+ .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"
- )
+ .setLabel(lastClicked == "clear-channel" ? "Click again to confirm" : "Clear Channel")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
.setCustomId("clear-channel")
.setDisabled(!config.welcome.channel)
@@ -335,9 +276,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
- throw new Error(
- "You must have the *Manage Server* permission to use this command"
- );
+ throw new Error("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 34c3152..d65109d 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,9 +1,4 @@
-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";
@@ -11,13 +6,7 @@
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);
@@ -28,11 +17,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag")
- .setDescription(
- `Tag \`${interaction.options.getString(
- "tag"
- )}\` does not exist`
- )
+ .setDescription(`Tag \`${interaction.options.getString("tag")}\` does not exist`)
.setEmoji("PUNISH.NICKNAME.RED")
.setStatus("Danger")
],
@@ -44,12 +29,7 @@
if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
url = tag;
components = [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Open")
- .setURL(url)
- .setStyle("LINK")
- ])
+ new MessageActionRow().addComponents([new MessageButton().setLabel("Open").setURL(url).setStyle("LINK")])
];
}
return await interaction.reply({
@@ -70,9 +50,7 @@
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/create.ts b/src/commands/tags/create.ts
index 5d6621b..6350ad7 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -9,24 +9,12 @@
builder
.setName("create")
.setDescription("Creates 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")
- )
- .addStringOption((o) =>
- o
- .setName("value")
- .setRequired(true)
- .setDescription(
- "The value of the tag, shown after running /tag name"
- )
+ 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)
@@ -34,9 +22,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag Create")
- .setDescription(
- "Tag names cannot be longer than 100 characters"
- )
+ .setDescription("Tag names cannot be longer than 100 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
@@ -47,9 +33,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag Create")
- .setDescription(
- "Tag values cannot be longer than 1000 characters"
- )
+ .setDescription("Tag values cannot be longer than 1000 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
@@ -110,9 +94,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag Create")
- .setDescription(
- "Something went wrong and the tag was not created"
- )
+ .setDescription("Something went wrong and the tag was not created")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index 4d1a1aa..1abdc48 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -9,16 +9,9 @@
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])
@@ -56,18 +49,14 @@
]
});
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"
- )
+ .setDescription("Something went wrong and the tag was not deleted")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 5aaec40..0ce306f 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -9,23 +9,12 @@
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("name")
- .setRequired(true)
- .setDescription("The tag to edit")
+ o.setName("value").setRequired(false).setDescription("The new value of the tag / Rename")
)
.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")
+ o.setName("newname").setRequired(false).setDescription("The new name of the tag / Edit")
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
@@ -49,9 +38,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag Edit")
- .setDescription(
- "Tag names cannot be longer than 100 characters"
- )
+ .setDescription("Tag names cannot be longer than 100 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
@@ -62,9 +49,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Tag Edit")
- .setDescription(
- "Tag values cannot be longer than 2000 characters"
- )
+ .setDescription("Tag values cannot be longer than 2000 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
@@ -124,19 +109,13 @@
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"
- )
+ .setDescription("Something went wrong and the tag was not edited")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
],
@@ -158,9 +137,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
if (!member.permissions.has("MANAGE_MESSAGES"))
- throw new Error(
- "You must have the *Manage Messages* permission to use this command"
- );
+ throw new Error("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 070aa8b..e62dee8 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -106,9 +106,7 @@
];
}
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([
@@ -145,28 +143,17 @@
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: [
@@ -198,12 +185,7 @@
}
}
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: [
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 71044dd..e2efcc3 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -2,8 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import close from "../../actions/tickets/delete.js";
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder.setName("close").setDescription("Closes a ticket");
+const command = (builder: SlashCommandSubcommandBuilder) => 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 10ec842..3d0b5ce 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -7,10 +7,7 @@
.setName("create")
.setDescription("Creates a new modmail ticket")
.addStringOption((option) =>
- option
- .setName("message")
- .setDescription("The content of the ticket")
- .setRequired(false)
+ option.setName("message").setDescription("The content of the ticket").setRequired(false)
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 129359f..64c1ceb 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -9,10 +9,7 @@
MessageComponentInteraction,
SelectMenuInteraction
} from "discord.js";
-import {
- SelectMenuOption,
- SlashCommandSubcommandBuilder
-} from "@discordjs/builders";
+import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
@@ -24,11 +21,7 @@
.setName("about")
.setDescription("Shows info about a user")
.addUserOption((option) =>
- option
- .setName("user")
- .setDescription(
- "The user to get info about | Default: Yourself"
- )
+ option.setName("user").setDescription("The user to get info about | Default: Yourself")
);
class Embed {
@@ -57,8 +50,7 @@
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
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 (
[
@@ -72,9 +64,7 @@
}
if (
(await client.guilds.cache.get("684492926528651336")?.members.fetch())
- ?.filter((m: GuildMember) =>
- m.roles.cache.has("760896837866749972")
- )
+ ?.filter((m: GuildMember) => m.roles.cache.has("760896837866749972"))
?.map((m: GuildMember) => m.id)
.includes(member.user.id)
) {
@@ -115,9 +105,7 @@
});
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;
@@ -149,12 +137,8 @@
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`;
+ const hasPerm = member.permissions.has(perm as Discord.PermissionString);
+ perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`;
});
let selectPaneOpen = false;
@@ -170,11 +154,7 @@
flags
.map((flag) => {
if (nameReplacements[flag]) {
- return (
- getEmojiByName(`BADGES.${flag}`) +
- " " +
- nameReplacements[flag]
- );
+ return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag];
}
})
.join("\n") +
@@ -183,26 +163,16 @@
member: renderUser(member.user),
nickname: member.nickname || "*None set*",
id: `\`${member.id}\``,
- "joined the server": renderDelta(
- member.joinedTimestamp
- ),
- "joined discord": renderDelta(
- member.user.createdTimestamp
- ),
+ "joined the server": renderDelta(member.joinedTimestamp),
+ "joined discord": renderDelta(member.user.createdTimestamp),
"boost status": member.premiumSince
- ? `Started boosting ${renderDelta(
- member.premiumSinceTimestamp
- )}`
+ ? `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" })
- )
+ .setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
+ .setImage((await member.user.fetch()).bannerURL({ format: "gif" }))
)
.setTitle("General")
.setDescription("General information about the user")
@@ -223,9 +193,7 @@
(s.length > 0 ? s : "*None*") +
"\n"
)
- .setThumbnail(
- member.user.displayAvatarURL({ dynamic: true })
- )
+ .setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
)
.setTitle("Roles")
.setDescription("Roles the user has")
@@ -244,9 +212,7 @@
"\n" +
perms
)
- .setThumbnail(
- member.user.displayAvatarURL({ dynamic: true })
- )
+ .setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
)
.setTitle("Key Permissions")
.setDescription("Key permissions the user has")
@@ -261,9 +227,7 @@
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) {
@@ -324,23 +288,15 @@
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 {
@@ -349,13 +305,7 @@
}
}
const em = new Discord.MessageEmbed(embeds[page].embed);
- em.setDescription(
- em.description +
- "\n" +
- createPageIndicator(embeds.length, page) +
- " | " +
- breakReason
- );
+ em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | " + breakReason);
await interaction.editReply({
embeds: [em],
components: [
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index 502e9c8..a6c319d 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -10,17 +10,12 @@
.setName("avatar")
.setDescription("Shows the avatar of a user")
.addUserOption((option) =>
- option
- .setName("user")
- .setDescription(
- "The user to get the avatar of | Default: Yourself"
- )
+ 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;
+ const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember;
await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -40,10 +35,7 @@
});
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 1a4c308..da62880 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,15 +1,6 @@
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";
// @ts-expect-error
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -21,25 +12,13 @@
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;
};
@@ -66,25 +45,16 @@
const dropdown = new Discord.MessageSelectMenu()
.addOptions(
config.tracks.map((option, index) => {
- const hasRoleInTrack = option.track.some(
- (element: string) => {
- return memberRoles.cache.has(element);
- }
- );
+ 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"),
+ description: option.track.length === 0 ? "No" : addPlural(option.track.length, "role"),
emoji: client.emojis.resolve(
- getEmojiByName(
- "TRACKS.SINGLE." +
- (hasRoleInTrack ? "ACTIVE" : "INACTIVE"),
- "id"
- )
+ getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id")
)
});
})
@@ -92,17 +62,9 @@
.setCustomId("select")
.setMaxValues(1);
const allowed = [];
- generated =
- "**Track:** " +
- data.name +
- "\n" +
- "**Member:** " +
- renderUser(member.user) +
- "\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";
+ (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"
@@ -112,18 +74,12 @@
data.track
.map((role, index) => {
const allow =
- roles.get(role).position >=
- (interaction.member as GuildMember).roles.highest
- .position && !managed;
+ 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
- )
+ generateFromTrack(index, memberRoles.cache.has(role), data.track.length, allow)
) +
" " +
roles.get(role).name +
@@ -141,15 +97,11 @@
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
- ) {
+ if (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) => {
@@ -172,10 +124,7 @@
"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: [
@@ -187,13 +136,7 @@
],
components: [new MessageActionRow().addComponents(dropdown)]
.concat(
- conflict && conflictDropdown.length
- ? [
- new MessageActionRow().addComponents(
- conflictDropdown
- )
- ]
- : []
+ conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : []
)
.concat([
new MessageActionRow().addComponents([
@@ -205,9 +148,7 @@
.setDisabled(
conflict ||
currentRoleIndex === 0 ||
- (currentRoleIndex === -1
- ? false
- : !allowed[currentRoleIndex - 1])
+ (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])
),
new MessageButton()
.setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
@@ -218,9 +159,7 @@
conflict ||
(data.nullable
? currentRoleIndex <= -1
- : currentRoleIndex ===
- data.track.length - 1 ||
- currentRoleIndex <= -1) ||
+ : currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1) ||
!allowed[currentRoleIndex]
)
])
@@ -234,9 +173,7 @@
}
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 (
@@ -247,16 +184,14 @@
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 (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]);
@@ -268,14 +203,9 @@
}
};
-const check = async (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
- const tracks = (await client.database.guilds.read(interaction.guild.id))
- .tracks;
- if (tracks.length === 0)
- throw new Error("This server does not have any tracks");
+const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+ const tracks = (await client.database.guilds.read(interaction.guild.id)).tracks;
+ if (tracks.length === 0) throw new Error("This server does not have any tracks");
const member = interaction.member as GuildMember;
// Allow the owner to promote anyone
if (member.id === interaction.guild.ownerId) return true;
@@ -283,12 +213,7 @@
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;
}
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index 2319284..f2c9c9d 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -4,18 +4,13 @@
import { WrappedCheck } from "jshaiku";
import verify from "../reflex/verify.js";
-const command = new SlashCommandBuilder()
- .setName("verify")
- .setDescription("Get verified in the server");
+const command = new SlashCommandBuilder().setName("verify").setDescription("Get verified in the server");
const callback = async (interaction: CommandInteraction): Promise<void> => {
verify(interaction);
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};
diff --git a/src/config/format.ts b/src/config/format.ts
index 7b68ebf..2035754 100644
--- a/src/config/format.ts
+++ b/src/config/format.ts
@@ -3,19 +3,16 @@
import * as readLine from "node:readline/promises";
const defaultDict = {
- developmentToken:
- "Your development bot token (Used for testing in one server, rather than production)",
+ developmentToken: "Your development bot token (Used for testing in one server, rather than production)",
developmentGuildID: "Your development guild ID",
enableDevelopment: true,
token: "Your bot token",
- managementGuildID:
- "Your management guild ID (Used for running management commands on the bot)",
+ managementGuildID: "Your management guild ID (Used for running management commands on the bot)",
owners: [],
verifySecret:
"If using verify, enter a code here which matches the secret sent back by your website. You can use a random code if you do not have one already. (Optional)",
mongoUrl: "Your Mongo connection string, e.g. mongodb://127.0.0.1:27017",
- baseUrl:
- "Your website where buttons such as Verify and Role menu will link to, e.g. https://example.com",
+ baseUrl: "Your website where buttons such as Verify and Role menu will link to, e.g. https://example.com",
pastebinApiKey: "An API key for pastebin (optional)",
pastebinUsername: "Your pastebin username (optional)",
pastebinPassword: "Your pastebin password (optional)"
@@ -35,12 +32,8 @@
export default async function (walkthrough = false) {
if (walkthrough) {
- console.log(
- "\x1b[33m🛈 Entering walkthrough mode for any missing values."
- );
- console.log(
- " \x1b[2mIf you don't want to enter a value, just hit enter.\x1b[0m\n"
- );
+ console.log("\x1b[33m🛈 Entering walkthrough mode for any missing values.");
+ console.log(" \x1b[2mIf you don't want to enter a value, just hit enter.\x1b[0m\n");
// let toUse = await getInput("\x1b[36m[Installing packages] Use Yarn or NPM? \x1b[0m(\x1b[32my\x1b[0m/\x1b[31mN\x1b[0m) > ");
// toUse = toUse.toLowerCase() === "y" ? "yarn install" : "npm i";
@@ -59,9 +52,7 @@
json = JSON.parse(fs.readFileSync("./src/config/main.json", "utf8"));
} catch (e) {
console.log("\x1b[31m⚠ No main.json found, creating one.");
- console.log(
- " \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n"
- );
+ console.log(" \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n");
out = false;
json = {};
}
@@ -93,9 +84,7 @@
break;
}
default: {
- json[key] = await getInput(
- `\x1b[36m${key} \x1b[0m(\x1b[35m${defaultDict[key]}\x1b[0m) > `
- );
+ json[key] = await getInput(`\x1b[36m${key} \x1b[0m(\x1b[35m${defaultDict[key]}\x1b[0m) > `);
}
}
} else {
@@ -103,8 +92,7 @@
}
}
}
- if (walkthrough && !json.mongoUrl)
- json.mongoUrl = "mongodb://127.0.0.1:27017";
+ if (walkthrough && !json.mongoUrl) json.mongoUrl = "mongodb://127.0.0.1:27017";
if (!json.mongoUrl.endsWith("/")) json.mongoUrl += "/";
if (!json.baseUrl.endsWith("/")) json.baseUrl += "/";
let hosts;
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index 7350ebd..19f5c9b 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,19 +1,9 @@
export const event = "channelCreate";
export async function callback(client, channel) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = channel.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger;
const auditLog = await getAuditLog(channel.guild, "CHANNEL_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === channel.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === channel.id).first();
if (audit.executor.id === client.user.id) return;
let emoji;
let readableType;
@@ -73,10 +63,7 @@
channel.parent ? channel.parent.name : "Uncategorised"
),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- channel.createdTimestamp,
- renderDelta(channel.createdTimestamp)
- )
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
},
hidden: {
guild: channel.guild.id
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index defb482..f39e7ed 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,15 +1,20 @@
+import {
+ BaseGuildTextChannel,
+ BaseGuildVoiceChannel,
+ GuildChannel,
+ StageChannel,
+ ThreadChannel,
+ VoiceChannel
+} from "discord.js";
+// @ts-expect-error
+import type { HaikuClient } from "jshaiku";
import getEmojiByName from "../utils/getEmojiByName.js";
export const event = "channelDelete";
-
-export async function callback(client, channel) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } =
- client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
const auditLog = await getAuditLog(channel.guild, "CHANNEL_DELETE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === channel.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === channel.id).first();
if (audit.executor.id === client.user.id) return;
let emoji;
@@ -60,27 +65,26 @@
channel.parent ? channel.parent.name : "Uncategorised"
),
nsfw: null,
- created: entry(
- channel.createdTimestamp,
- renderDelta(channel.createdTimestamp)
- ),
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
deletedBy: entry(audit.executor.id, renderUser(audit.executor))
};
- if (channel.topic !== null ?? false)
- list.topic = entry(
- channel.topic,
- `\`\`\`\n${channel.topic.replace("`", "'")}\n\`\`\``
- );
+ if ((channel instanceof BaseGuildTextChannel || channel instanceof StageChannel) && channel.topic !== null)
+ list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace("`", "'")}\n\`\`\``);
else delete list.topic;
- if (channel.nsfw !== null ?? false)
+ if (
+ channel instanceof BaseGuildTextChannel ||
+ channel instanceof VoiceChannel ||
+ channel instanceof ThreadChannel
+ ) {
+ const nsfw = channel instanceof ThreadChannel ? (channel as ThreadChannel).parent?.nsfw ?? false : channel.nsfw;
list.nsfw = entry(
- channel.nsfw,
- channel.nsfw
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`
+ nsfw,
+ nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
);
- else delete list.nsfw;
+ } else {
+ delete list.nsfw;
+ }
const data = {
meta: {
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 6717661..a7af453 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -5,22 +5,12 @@
export async function callback(client, oc, nc) {
const config = await client.memory.readGuildInfo(nc.guild.id);
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderDelta,
- renderUser,
- renderChannel
- } = client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger;
if (nc.parent && nc.parent.id === config.tickets.category) return;
const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === nc.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === nc.id).first();
if (audit.executor.id === client.user.id) return;
let emoji: string;
@@ -30,18 +20,11 @@
channelId: entry(nc.id, `\`${nc.id}\``),
channel: entry(nc.id, renderChannel(nc)),
edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- editedBy: entry(
- audit.executor.id,
- renderUser((await nc.guild.members.fetch(audit.executor.id)).user)
- )
+ editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user))
};
- if (oc.name !== nc.name)
- changes.name = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+ if (oc.name !== nc.name) changes.name = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
if (oc.position !== nc.position)
- changes.position = entry(
- [oc.position, nc.position],
- `${oc.position} -> ${nc.position}`
- );
+ changes.position = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
switch (nc.type) {
case "GUILD_TEXT": {
@@ -52,45 +35,28 @@
newTopic = nc.topic;
if (oldTopic) {
if (oldTopic.length > 256)
- oldTopic = `\`\`\`\n${
- oldTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
} else {
oldTopic = "None";
}
if (newTopic) {
if (newTopic.length > 256)
- newTopic = `\`\`\`\n${
- newTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
} else {
newTopic = "None";
}
const nsfw = ["", ""];
- nsfw[0] = oc.nsfw
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
- nsfw[1] = nc.nsfw
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
+ nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
if (oc.topic !== nc.topic)
- changes.description = entry(
- [oc.topic, nc.topic],
- `\nBefore: ${oldTopic}\nAfter: ${newTopic}`
- );
- if (oc.nsfw !== nc.nsfw)
- changes.nsfw = entry(
- [oc.nsfw, nc.nsfw],
- `${nsfw[0]} -> ${nsfw[1]}`
- );
+ changes.description = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+ if (oc.nsfw !== nc.nsfw) changes.nsfw = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
if (oc.rateLimitPerUser !== nc.rateLimitPerUser)
changes.rateLimitPerUser = entry(
[oc.rateLimitPerUser, nc.rateLimitPerUser],
- `${humanizeDuration(
- oc.rateLimitPerUser * 1000
- )} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+ `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
);
break;
@@ -103,27 +69,20 @@
newTopic = nc.topic;
if (oldTopic) {
if (oldTopic.length > 256)
- oldTopic = `\`\`\`\n${
- oldTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
} else {
oldTopic = "None";
}
if (newTopic) {
if (newTopic.length > 256)
- newTopic = `\`\`\`\n${
- newTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
} else {
newTopic = "None";
}
if (oc.nsfw !== nc.nsfw)
- changes.nsfw = entry(
- [oc.nsfw, nc.nsfw],
- `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`
- );
+ changes.nsfw = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
break;
}
case "GUILD_VOICE": {
@@ -131,23 +90,16 @@
readableType = "Voice";
displayName = "Voice Channel";
if (oc.bitrate !== nc.bitrate)
- changes.bitrate = entry(
- [oc.bitrate, nc.bitrate],
- `${oc.bitrate} -> ${nc.bitrate}`
- );
+ changes.bitrate = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
if (oc.userLimit !== nc.userLimit)
changes.maxUsers = entry(
[oc.userLimit, nc.userLimit],
- `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${
- nc.userLimit
- }`
+ `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`
);
if (oc.rtcRegion !== nc.rtcRegion)
changes.region = entry(
[oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${
- nc.rtcRegion || "Automatic"
- }`
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
);
break;
}
@@ -159,40 +111,29 @@
newTopic = nc.topic;
if (oldTopic) {
if (oldTopic.length > 256)
- oldTopic = `\`\`\`\n${
- oldTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
} else {
oldTopic = "None";
}
if (newTopic) {
if (newTopic.length > 256)
- newTopic = `\`\`\`\n${
- newTopic.replace("`", "'").substring(0, 253) + "..."
- }\n\`\`\``;
+ newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
} else {
newTopic = "None";
}
if (oc.bitrate !== nc.bitrate)
- changes.bitrate = entry(
- [oc.bitrate, nc.bitrate],
- `${oc.bitrate} -> ${nc.bitrate}`
- );
+ changes.bitrate = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
if (oc.userLimit !== nc.userLimit)
changes.maxUsers = entry(
[oc.userLimit, nc.userLimit],
- `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${
- nc.userLimit
- }`
+ `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`
);
if (oc.rtcRegion !== nc.rtcRegion)
changes.region = entry(
[oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${
- nc.rtcRegion || "Automatic"
- }`
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
);
break;
}
@@ -210,10 +151,7 @@
}
const t = oc.type.split("_")[1];
if (oc.type !== nc.type)
- changes.type = entry(
- [oc.type, nc.type],
- `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`
- );
+ changes.type = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
if (!(Object.values(changes).length - 4)) return;
const data = {
meta: {
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 53f564c..b4e9dfa 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,19 +1,9 @@
export const event = "emojiCreate";
export async function callback(client, emoji) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderEmoji
- } = emoji.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
const auditLog = await getAuditLog(emoji.guild, "EMOJI_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === emoji.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === emoji.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -28,10 +18,7 @@
emojiId: entry(emoji.id, `\`${emoji.id}\``),
emoji: entry(emoji.name, renderEmoji(emoji)),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- emoji.createdTimestamp,
- renderDelta(emoji.createdTimestamp)
- )
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 041b432..c4b1535 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,19 +1,9 @@
export const event = "emojiDelete";
export async function callback(client, emoji) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderEmoji
- } = emoji.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
const auditLog = await getAuditLog(emoji.guild, "EMOJI_DELETE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === emoji.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === emoji.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -28,14 +18,8 @@
emojiId: entry(emoji.id, `\`${emoji.id}\``),
emoji: entry(emoji.name, renderEmoji(emoji)),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- emoji.createdTimestamp,
- renderDelta(emoji.createdTimestamp)
- ),
- deleted: entry(
- audit.createdTimestamp,
- renderDelta(audit.createdTimestamp)
- )
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+ deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 34b16de..66227d4 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,15 +1,7 @@
export const event = "emojiUpdate";
export async function callback(client, oe, ne) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderDelta,
- renderUser,
- renderEmoji
- } = client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
if (oe.name === ne.name) return;
const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
@@ -20,10 +12,7 @@
emojiId: entry(ne.id, `\`${ne.id}\``),
emoji: entry(ne.id, renderEmoji(ne)),
edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
- editedBy: entry(
- audit.executor.id,
- renderUser((await ne.guild.members.fetch(audit.executor.id)).user)
- ),
+ editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
};
const data = {
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index dd723d3..17c4595 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -6,20 +6,11 @@
export async function callback(client, ban) {
await statsChannelRemove(client, ban.user);
purgeByUser(ban.user.id, ban.guild);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } =
- ban.user.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_ADD");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === ban.user.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === ban.user.id).first();
if (audit.executor.id === client.user.id) return;
- await client.database.history.create(
- "ban",
- ban.guild.id,
- ban.user,
- audit.executor,
- audit.reason
- );
+ await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason);
const data = {
meta: {
type: "memberBan",
@@ -32,19 +23,10 @@
list: {
memberId: entry(ban.user.id, `\`${ban.user.id}\``),
name: entry(ban.user.id, renderUser(ban.user)),
- banned: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(
- audit.reason,
- audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"
- ),
- accountCreated: entry(
- ban.user.createdAt,
- renderDelta(ban.user.createdAt)
- ),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
serverMemberCount: ban.guild.memberCount
},
hidden: {
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 4c2263d..74b7c4e 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -6,20 +6,11 @@
export async function callback(client, ban) {
await statsChannelRemove(client, ban.user);
purgeByUser(ban.user.id, ban.guild);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } =
- ban.user.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_REMOVE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === ban.user.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === ban.user.id).first();
if (audit.executor.id === client.user.id) return;
- await client.database.history.create(
- "unban",
- ban.guild.id,
- ban.user,
- audit.executor,
- audit.reason
- );
+ await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason);
const data = {
meta: {
type: "memberUnban",
@@ -32,15 +23,9 @@
list: {
memberId: entry(ban.user.id, `\`${ban.user.id}\``),
name: entry(ban.user.id, renderUser(ban.user)),
- unbanned: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
- accountCreated: entry(
- ban.user.createdAt,
- renderDelta(ban.user.createdAt)
- )
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt))
},
hidden: {
guild: ban.guild.id
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 4cffe69..08730f2 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -2,18 +2,9 @@
export async function callback(client, before, after) {
try {
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- getAuditLog
- } = after.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger;
const auditLog = await getAuditLog(after.guild, "MEMBER_UPDATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === after.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === after.id).first();
if (audit.executor.id === client.user.id) return;
if (before.nickname !== after.nickname) {
await client.database.history.create(
@@ -37,22 +28,10 @@
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- before: entry(
- before.nickname,
- before.nickname ? before.nickname : "*None*"
- ),
- after: entry(
- after.nickname,
- after.nickname ? after.nickname : "*None*"
- ),
- changed: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
- changedBy: entry(
- audit.executor.id,
- renderUser(audit.executor)
- )
+ before: entry(before.nickname, before.nickname ? before.nickname : "*None*"),
+ after: entry(after.nickname, after.nickname ? after.nickname : "*None*"),
+ changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ changedBy: entry(audit.executor.id, renderUser(audit.executor))
},
hidden: {
guild: after.guild.id
@@ -89,33 +68,20 @@
after.communicationDisabledUntilTimestamp,
renderDelta(after.communicationDisabledUntilTimestamp)
),
- muted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
- mutedBy: entry(
- audit.executor.id,
- renderUser(audit.executor)
- ),
- reason: entry(
- audit.reason,
- audit.reason ? audit.reason : "\n> *No reason provided*"
- )
+ muted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ mutedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ reason: entry(audit.reason, audit.reason ? audit.reason : "\n> *No reason provided*")
},
hidden: {
guild: after.guild.id
}
};
log(data);
- client.database.eventScheduler.schedule(
- "naturalUnmute",
- after.communicationDisabledUntil,
- {
- guild: after.guild.id,
- user: after.id,
- expires: after.communicationDisabledUntilTimestamp
- }
- );
+ client.database.eventScheduler.schedule("naturalUnmute", after.communicationDisabledUntil, {
+ guild: after.guild.id,
+ user: after.id,
+ expires: after.communicationDisabledUntilTimestamp
+ });
} else if (
after.communicationDisabledUntil === null &&
before.communicationDisabledUntilTimestamp !== null &&
@@ -143,14 +109,8 @@
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- unmuted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
- unmutedBy: entry(
- audit.executor.id,
- renderUser(audit.executor)
- )
+ unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unmutedBy: entry(audit.executor.id, renderUser(audit.executor))
},
hidden: {
guild: after.guild.id
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index 2c87807..a165770 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -4,12 +4,9 @@
export async function callback(client, before, after) {
await statsChannelUpdate(client, after.me);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- after.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
const auditLog = await getAuditLog(after, "GUILD_UPDATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === after.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === after.id).first();
if (audit.executor.id === client.user.id) return;
const list = {};
@@ -32,16 +29,9 @@
ELEVATED: "Enabled"
};
- if (before.name !== after.name)
- list.name = entry(
- [before.name, after.name],
- `${before.name} -> ${after.name}`
- );
+ if (before.name !== after.name) list.name = entry([before.name, after.name], `${before.name} -> ${after.name}`);
if (before.icon !== after.icon)
- list.icon = entry(
- [before.icon, after.icon],
- `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`
- );
+ list.icon = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
if (before.splash !== after.splash)
list.splash = entry(
[before.splash, after.splash],
@@ -55,19 +45,12 @@
if (before.owner !== after.owner)
list.owner = entry(
[before.owner, after.owner],
- `${renderUser(before.owner.user)} -> ${renderUser(
- after.owner.user
- )}`
+ `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`
);
if (before.verificationLevel !== after.verificationLevel)
list.verificationLevel = entry(
- [
- verificationLevels[before.verificationLevel],
- verificationLevels[after.verificationLevel]
- ],
- `${verificationLevels[before.verificationLevel]} -> ${
- verificationLevels[after.verificationLevel]
- }`
+ [verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]],
+ `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`
);
if (before.explicitContentFilter !== after.explicitContentFilter)
list.explicitContentFilter = entry(
@@ -86,10 +69,7 @@
);
if (!Object.keys(list).length) return;
- list.updated = entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- );
+ list.updated = entry(new Date().getTime(), renderDelta(new Date().getTime()));
list.updatedBy = entry(audit.executor.id, renderUser(audit.executor));
const data = {
meta: {
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 60b90e3..5b0aff1 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -20,25 +20,16 @@
findAllMatches: true,
minMatchCharLength: 0
}).search(typed);
- return fuse
- .slice(0, 25)
- .map((option) => ({ name: option.item, value: option.item }));
+ return fuse.slice(0, 25).map((option) => ({ name: option.item, value: option.item }));
}
function generateStatsChannelAutocomplete(typed) {
- const validReplacements = [
- "serverName",
- "memberCount",
- "memberCount:bots",
- "memberCount:humans"
- ];
+ const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"];
const autocompletions = [];
const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
if (beforeLastOpenBracket !== null) {
for (const replacement of validReplacements) {
- autocompletions.push(
- `${beforeLastOpenBracket[1]} {${replacement}}`
- );
+ autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`);
}
} else {
for (const replacement of validReplacements) {
@@ -60,9 +51,7 @@
const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
if (beforeLastOpenBracket !== null) {
for (const replacement of validReplacements) {
- autocompletions.push(
- `${beforeLastOpenBracket[1]} {${replacement}}`
- );
+ autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`);
}
} else {
for (const replacement of validReplacements) {
@@ -93,32 +82,21 @@
}
} else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
switch (
- `${
- interaction.commandName
- } ${interaction.options.getSubcommandGroup(
+ `${interaction.commandName} ${interaction.options.getSubcommandGroup(
false
)} ${interaction.options.getSubcommand(false)}`
) {
case "tag null null": {
return interaction.respond(
- getAutocomplete(
- interaction.options.getString("tag"),
- await tagAutocomplete(interaction)
- )
+ getAutocomplete(interaction.options.getString("tag"), await tagAutocomplete(interaction))
);
}
case "settings null stats": {
- return interaction.respond(
- generateStatsChannelAutocomplete(
- interaction.options.getString("name")
- )
- );
+ return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name")));
}
case "settings null welcome": {
return interaction.respond(
- generateWelcomeMessageAutocomplete(
- interaction.options.getString("message")
- )
+ generateWelcomeMessageAutocomplete(interaction.options.getString("message"))
);
}
}
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5461307..7b23bb2 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -2,19 +2,9 @@
export const event = "inviteCreate";
export async function callback(client, invite) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = invite.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
const auditLog = await getAuditLog(invite.guild, "INVITE_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === invite.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === invite.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -28,15 +18,9 @@
list: {
channel: entry(invite.channel.id, renderChannel(invite.channel)),
link: entry(invite.url, invite.url),
- expires: entry(
- invite.maxAge,
- invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"
- ),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- invite.createdTimestamp,
- renderDelta(invite.createdTimestamp)
- )
+ created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
},
hidden: {
guild: invite.guild.id
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index e5bf241..2cd3bc5 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -2,19 +2,9 @@
export const event = "inviteDelete";
export async function callback(client, invite) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = invite.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === invite.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === invite.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -28,15 +18,9 @@
list: {
channel: entry(invite.channel.id, renderChannel(invite.channel)),
link: entry(invite.url, invite.url),
- expires: entry(
- invite.maxAge,
- invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"
- ),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {
guild: invite.guild.id
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index ea0b24d..ebc2934 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -7,15 +7,8 @@
export async function callback(_, member) {
welcome(_, member);
statsChannelAdd(_, member);
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- member.client.logger;
- await client.database.history.create(
- "join",
- member.guild.id,
- member.user,
- null,
- null
- );
+ const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ await client.database.history.create("join", member.guild.id, member.user, null, null);
const data = {
meta: {
type: "memberJoin",
@@ -29,10 +22,7 @@
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- accountCreated: entry(
- member.user.createdAt,
- renderDelta(member.user.createdAt)
- ),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount
},
hidden: {
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index d170396..00f6d84 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -6,12 +6,9 @@
export async function callback(client, member) {
purgeByUser(member.id, member.guild);
await statsChannelRemove(client, member);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- member.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === member.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === member.id).first();
let type = "leave";
if (audit) {
if (audit.executor.id === client.user.id) return;
@@ -21,13 +18,7 @@
}
let data;
if (type === "kick") {
- await client.database.history.create(
- "kick",
- member.guild.id,
- member.user,
- audit.executor,
- audit.reason
- );
+ await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
data = {
meta: {
type: "memberKick",
@@ -41,21 +32,10 @@
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())
- ),
+ kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(
- audit.reason,
- audit.reason
- ? `\n> ${audit.reason}`
- : "*No reason provided.*"
- ),
- accountCreated: entry(
- member.user.createdAt,
- renderDelta(member.user.createdAt)
- ),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount
},
hidden: {
@@ -63,13 +43,7 @@
}
};
} else {
- await client.database.history.create(
- "leave",
- member.guild.id,
- member.user,
- null,
- null
- );
+ await client.database.history.create("leave", member.guild.id, member.user, null, null);
data = {
meta: {
type: "memberLeave",
@@ -82,18 +56,9 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: entry(
- member.joinedTimestamp,
- renderDelta(member.joinedAt)
- ),
- left: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
- accountCreated: entry(
- member.user.createdAt,
- renderDelta(member.user.createdAt)
- ),
+ joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+ left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount
},
hidden: {
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 7e4a52f..f690885 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,13 +1,6 @@
// @ts-expect-error
import { HaikuClient } from "jshaiku";
-import {
- LinkCheck,
- MalwareCheck,
- NSFWCheck,
- SizeCheck,
- TestString,
- TestImage
-} from "../reflex/scanners.js";
+import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
import logAttachment from "../premium/attachmentLogs.js";
import createLogException from "../utils/createLogException.js";
import getEmojiByName from "../utils/getEmojiByName.js";
@@ -27,14 +20,7 @@
console.log(e);
}
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const fileNames = await logAttachment(message);
@@ -43,9 +29,7 @@
const filter = getEmojiByName("ICONS.FILTER");
let attachmentJump = "";
if (config.logging.attachments.saved[message.channel.id + message.id]) {
- attachmentJump = ` [[View attachments]](${
- config.logging.attachments.saved[message.channel.id + message.id]
- })`;
+ attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`;
}
const list = {
messageId: entry(message.id, `\`${message.id}\``),
@@ -53,10 +37,7 @@
sentIn: entry(message.channel.id, renderChannel(message.channel)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
mentions: message.mentions.users.size,
- attachments: entry(
- message.attachments.size,
- message.attachments.size + attachmentJump
- ),
+ attachments: entry(message.attachments.size, message.attachments.size + attachmentJump),
repliedTo: entry(
message.reference ? message.reference.messageId : null,
message.reference
@@ -66,25 +47,14 @@
};
if (config.filters.invite.enabled) {
- if (
- !config.filters.invite.allowed.channels.includes(message.channel.id)
- ) {
- if (
- /(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(
- content
- )
- ) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
+ if (/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content)) {
+ createLogException(message.guild.id, message.channel.id, message.id);
message.delete();
const data = {
meta: {
type: "messageDelete",
- displayName:
- "Message Deleted (Automated, Contained Invite)",
+ displayName: "Message Deleted (Automated, Contained Invite)",
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
@@ -94,9 +64,7 @@
start:
filter +
" Contained invite\n\n" +
- (content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*")
+ (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -111,21 +79,13 @@
if (fileNames.files.length > 0) {
for (const element of fileNames.files) {
const url = element.url ? element.url : element.local;
- if (
- /\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)
- ) {
+ if (/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
if (
config.filters.images.NSFW &&
- !(message.channel instanceof ThreadChannel
- ? message.channel.parent?.nsfw
- : message.channel.nsfw)
+ !(message.channel instanceof ThreadChannel ? message.channel.parent?.nsfw : message.channel.nsfw)
) {
if (await NSFWCheck(url)) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -160,11 +120,7 @@
config.filters.wordFilter.words.strict
);
if (check !== null) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -194,11 +150,7 @@
if (config.filters.images.size) {
if (url.match(/\.+(webp|png|jpg)$/gi)) {
if (!(await SizeCheck(element))) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -229,11 +181,7 @@
}
if (config.filters.malware) {
if (!(await MalwareCheck(url))) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -280,9 +228,7 @@
start:
filter +
` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` +
- (content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*")
+ (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -299,11 +245,7 @@
config.filters.wordFilter.words.strict
);
if (check !== null) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -318,9 +260,7 @@
start:
filter +
" Message contained filtered word\n\n" +
- (content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*")
+ (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -342,9 +282,7 @@
timestamp: new Date().getTime()
},
separate: {
- start: content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*"
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: list,
hidden: {
@@ -356,11 +294,7 @@
if (config.filters.pings.roles) {
for (const roleId in message.mentions.roles) {
if (!config.filters.pings.allowed.roles.includes(roleId)) {
- createLogException(
- message.guild.id,
- message.channel.id,
- message.id
- );
+ createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
meta: {
@@ -385,10 +319,7 @@
}
}
}
- if (
- message.mentions.users.size >= config.filters.pings.mass &&
- config.filters.pings.mass
- ) {
+ if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
@@ -401,9 +332,7 @@
timestamp: new Date().getTime()
},
separate: {
- start: content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*"
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: list,
hidden: {
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 4cdbdb2..3a72876 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -3,25 +3,11 @@
export async function callback(client, message) {
try {
if (message.author.id === client.user.id) return;
- if (
- client.noLog.includes(
- `${message.guild.id}/${message.channel.id}/${message.id}`
- )
- )
- return;
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = message.channel.client.logger;
+ if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } =
+ message.channel.client.logger;
const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === message.author.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === message.author.id).first();
if (audit) {
if (audit.createdAt - 100 < new Date().getTime()) return;
}
@@ -37,8 +23,9 @@
) ?? []
).length;
let attachmentJump = "";
- const config = (await client.database.guilds.read(message.guild.id))
- .logging.attachments.saved[message.channel.id + message.id];
+ const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[
+ message.channel.id + message.id
+ ];
if (config) {
attachmentJump = ` [[View attachments]](${config})`;
}
@@ -52,21 +39,13 @@
timestamp: new Date().getTime()
},
separate: {
- start: content
- ? `**Message:**\n\`\`\`${content}\`\`\``
- : "**Message:** *Message had no content*"
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: {
messageId: entry(message.id, `\`${message.id}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
- sentIn: entry(
- message.channel.id,
- renderChannel(message.channel)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ sentIn: entry(message.channel.id, renderChannel(message.channel)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
mentions: message.mentions.users.size,
attachments: entry(attachments, attachments + attachmentJump),
repliedTo: entry(
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index c83512c..1470832 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,29 +2,20 @@
export async function callback(client, oldMessage, newMessage) {
if (newMessage.author.id === client.user.id) return;
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderNumberDelta,
- renderChannel
- } = newMessage.channel.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } =
+ newMessage.channel.client.logger;
newMessage.reference = newMessage.reference || {};
let newContent = newMessage.cleanContent.replaceAll("`", "‘");
let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
let attachmentJump = "";
- const config = (await client.database.guilds.read(newMessage.guild.id))
- .logging.attachments.saved[newMessage.channel.id + newMessage.id];
+ const config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[
+ newMessage.channel.id + newMessage.id
+ ];
if (config) {
attachmentJump = ` [[View attachments]](${config})`;
}
if (newContent === oldContent) {
- if (
- !oldMessage.flags.has("CROSSPOSTED") &&
- newMessage.flags.has("CROSSPOSTED")
- ) {
+ if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
const data = {
meta: {
type: "messageAnnounce",
@@ -39,14 +30,8 @@
},
list: {
messageId: entry(newMessage.id, `\`${newMessage.id}\``),
- sentBy: entry(
- newMessage.author.id,
- renderUser(newMessage.author)
- ),
- sentIn: entry(
- newMessage.channel.id,
- renderChannel(newMessage.channel)
- ),
+ sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
sent: entry(
new Date(newMessage.createdTimestamp),
renderDelta(new Date(newMessage.createdTimestamp))
@@ -55,19 +40,10 @@
new Date(newMessage.editedTimestamp),
renderDelta(new Date(newMessage.editedTimestamp))
),
- mentions: renderNumberDelta(
- oldMessage.mentions.users.size,
- newMessage.mentions.users.size
- ),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
attachments: entry(
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ),
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ) + attachmentJump
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
)
},
hidden: {
@@ -80,10 +56,8 @@
if (!newMessage.editedTimestamp) {
return;
}
- if (newContent.length > 256)
- newContent = newContent.substring(0, 253) + "...";
- if (oldContent.length > 256)
- oldContent = oldContent.substring(0, 253) + "...";
+ if (newContent.length > 256) newContent = newContent.substring(0, 253) + "...";
+ if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + "...";
const data = {
meta: {
type: "messageUpdate",
@@ -98,39 +72,19 @@
(oldContent
? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n`
: "**Before:** *Message had no content*\n") +
- (newContent
- ? `**After:**\n\`\`\`\n${newContent}\n\`\`\``
- : "**After:** *Message had no content*"),
+ (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : "**After:** *Message had no content*"),
end: `[[Jump to message]](${newMessage.url})`
},
list: {
messageId: entry(newMessage.id, `\`${newMessage.id}\``),
sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(
- newMessage.channel.id,
- renderChannel(newMessage.channel)
- ),
- sent: entry(
- new Date(newMessage.createdTimestamp),
- renderDelta(new Date(newMessage.createdTimestamp))
- ),
- edited: entry(
- new Date(newMessage.editedTimestamp),
- renderDelta(new Date(newMessage.editedTimestamp))
- ),
- mentions: renderNumberDelta(
- oldMessage.mentions.users.size,
- newMessage.mentions.users.size
- ),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+ sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+ edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
attachments: entry(
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ),
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ) + attachmentJump
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
),
repliedTo: entry(
newMessage.reference.messageId || null,
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index f0051a0..f1b0a91 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,20 +1,10 @@
export const event = "roleCreate";
export async function callback(client, role) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderRole
- } = role.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
if (role.managed) return;
const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === role.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === role.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -29,10 +19,7 @@
roleId: entry(role.id, `\`${role.id}\``),
role: entry(role.name, renderRole(role)),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- role.createdTimestamp,
- renderDelta(role.createdTimestamp)
- )
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
},
hidden: {
guild: role.guild.id
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 185ea8e..4807e7d 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,13 +3,10 @@
export const event = "roleDelete";
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- role.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger;
if (role.managed) return;
const auditLog = await getAuditLog(role.guild, "ROLE_DELETE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === role.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === role.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -26,26 +23,16 @@
color: entry(role.hexColor, `\`${role.hexColor}\``),
showInMemberList: entry(
role.hoist,
- role.hoist
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`
+ role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
),
mentionable: entry(
role.mentionable,
- role.mentionable
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`
+ role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
),
members: entry(role.members.size, `${role.members.size}`),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- role.createdTimestamp,
- renderDelta(role.createdTimestamp)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {
guild: role.guild.id
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index be276e5..53bbdee 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -3,15 +3,7 @@
export const event = "roleUpdate";
export async function callback(client, or, nr) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderDelta,
- renderUser,
- renderRole
- } = client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
const auditLog = await getAuditLog(nr.guild, "ROLE_UPDATE");
const audit = auditLog.entries.first();
@@ -21,47 +13,22 @@
roleId: entry(nr.id, `\`${nr.id}\``),
role: entry(nr.id, renderRole(nr)),
edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- editedBy: entry(
- audit.executor.id,
- renderUser((await nr.guild.members.fetch(audit.executor.id)).user)
- )
+ editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user))
};
const mentionable = ["", ""];
const hoist = ["", ""];
- mentionable[0] = or.mentionable
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
- mentionable[1] = nr.mentionable
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
- hoist[0] = or.hoist
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
- hoist[1] = nr.hoist
- ? `${getEmojiByName("CONTROL.TICK")} Yes`
- : `${getEmojiByName("CONTROL.CROSS")} No`;
- if (or.name !== nr.name)
- changes.name = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+ mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ if (or.name !== nr.name) changes.name = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
if (or.position !== nr.position)
- changes.position = entry(
- [or.position, nr.position],
- `${or.position} -> ${nr.position}`
- );
- if (or.hoist !== nr.hoist)
- changes.showInMemberList = entry(
- [or.hoist, nr.hoist],
- `${hoist[0]} -> ${hoist[1]}`
- );
+ changes.position = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+ if (or.hoist !== nr.hoist) changes.showInMemberList = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
if (or.mentionable !== nr.mentionable)
- changes.mentionable = entry(
- [or.mentionable, nr.mentionable],
- `${mentionable[0]} -> ${mentionable[1]}`
- );
+ changes.mentionable = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
if (or.hexColor !== nr.hexColor)
- changes.color = entry(
- [or.hexColor, nr.hexColor],
- `\`${or.hexColor}\` -> \`${nr.hexColor}\``
- );
+ changes.color = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
if (Object.keys(changes).length === 4) return;
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 54de270..c538bde 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,12 +1,9 @@
export const event = "stickerCreate";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- emoji.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
const auditLog = await getAuditLog(emoji.guild, "STICKER_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === emoji.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === emoji.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -21,10 +18,7 @@
stickerId: entry(emoji.id, `\`${emoji.id}\``),
emoji: entry(emoji.name, `\`:${emoji.name}:\``),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- emoji.createdTimestamp,
- renderDelta(emoji.createdTimestamp)
- )
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index f390b5c..7ac17ce 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,12 +1,9 @@
export const event = "stickerDelete";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- emoji.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === emoji.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === emoji.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -21,14 +18,8 @@
stickerId: entry(emoji.id, `\`${emoji.id}\``),
sticker: entry(emoji.name, `\`${emoji.name}\``),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- emoji.createdTimestamp,
- renderDelta(emoji.createdTimestamp)
- ),
- deleted: entry(
- audit.createdTimestamp,
- renderDelta(audit.createdTimestamp)
- )
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+ deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 46c4d17..662f981 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,8 +1,7 @@
export const event = "stickerUpdate";
export async function callback(client, oe, ne) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } =
- client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
if (oe.name === ne.name) return;
const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
@@ -12,10 +11,7 @@
const changes = {
stickerId: entry(ne.id, `\`${ne.id}\``),
edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
- editedBy: entry(
- audit.executor.id,
- renderUser((await ne.guild.members.fetch(audit.executor.id)).user)
- ),
+ editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
};
const data = {
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index 4fdedcb..da3cbae 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -2,19 +2,9 @@
export const event = "threadCreate";
export async function callback(client, thread) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = thread.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
const auditLog = await getAuditLog(thread.guild, "THREAD_CREATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === thread.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === thread.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -31,9 +21,7 @@
parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
category: entry(
thread.parent.parent ? thread.parent.parent.name : "None",
- thread.parent.parent
- ? renderChannel(thread.parent.parent)
- : "None"
+ thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
),
autoArchiveDuration: entry(
thread.autoArchiveDuration,
@@ -42,10 +30,7 @@
})
),
createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- thread.createdTimestamp,
- renderDelta(thread.createdTimestamp)
- )
+ created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
},
hidden: {
guild: thread.guild.id
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 0077eff..bfae11a 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -2,19 +2,9 @@
export const event = "threadDelete";
export async function callback(client, thread) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = thread.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === thread.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === thread.id).first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -31,9 +21,7 @@
parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
category: entry(
thread.parent.parent ? thread.parent.parent.name : "None",
- thread.parent.parent
- ? renderChannel(thread.parent.parent)
- : "None"
+ thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
),
autoArchiveDuration: entry(
thread.autoArchiveDuration,
@@ -43,14 +31,8 @@
),
membersInThread: entry(thread.memberCount, thread.memberCount),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(
- thread.createdTimestamp,
- renderDelta(thread.createdTimestamp)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {
guild: thread.guild.id
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index ff36ce0..144dc84 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -2,19 +2,9 @@
export const event = "threadUpdate";
export async function callback(client, before, after) {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderChannel
- } = after.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
const auditLog = await getAuditLog(after.guild, "THREAD_UPDATE");
- const audit = auditLog.entries
- .filter((entry) => entry.target.id === after.id)
- .first();
+ const audit = auditLog.entries.filter((entry) => entry.target.id === after.id).first();
if (audit.executor.id === client.user.id) return;
const list = {
threadId: entry(after.id, `\`${after.id}\``),
@@ -22,10 +12,7 @@
parentChannel: entry(after.parentId, renderChannel(after.parent))
};
if (before.name !== after.name) {
- list.name = entry(
- [before.name, after.name],
- `${before.name} -> ${after.name}`
- );
+ list.name = entry([before.name, after.name], `${before.name} -> ${after.name}`);
}
if (before.autoArchiveDuration !== after.autoArchiveDuration) {
list.autoArchiveDuration = entry(
@@ -40,16 +27,11 @@
if (before.rateLimitPerUser !== after.rateLimitPerUser) {
list.slowmode = entry(
[before.rateLimitPerUser, after.rateLimitPerUser],
- `${humanizeDuration(
- before.rateLimitPerUser * 1000
- )} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`
+ `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`
);
}
if (!(Object.keys(list).length - 3)) return;
- list.updated = entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- );
+ list.updated = entry(new Date().getTime(), renderDelta(new Date().getTime()));
list.updatedBy = entry(audit.executor.id, renderUser(audit.executor));
const data = {
meta: {
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index ae88cac..2e95c4b 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -3,20 +3,9 @@
import type { HaikuClient } from "jshaiku";
export const event = "webhookUpdate";
-export async function callback(
- client: HaikuClient,
- channel: Discord.GuildChannel
-) {
+export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
try {
- const {
- getAuditLog,
- log,
- NucleusColors,
- entry,
- renderUser,
- renderChannel,
- renderDelta
- } = client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
let auditLogCreate = getAuditLog(channel.guild, "WEBHOOK_CREATE");
let auditLogUpdate = getAuditLog(channel.guild, "WEBHOOK_UPDATE");
let auditLogDelete = getAuditLog(channel.guild, "WEBHOOK_DELETE");
@@ -25,15 +14,9 @@
auditLogUpdate,
auditLogDelete
]);
- const auditCreate = auditLogCreate.entries
- .filter((entry) => entry.target.channelId === channel.id)
- .first();
- const auditUpdate = auditLogUpdate.entries
- .filter((entry) => entry.target.channelId === channel.id)
- .first();
- const auditDelete = auditLogDelete.entries
- .filter((entry) => entry.target.channelId === channel.id)
- .first();
+ const auditCreate = auditLogCreate.entries.filter((entry) => entry.target.channelId === channel.id).first();
+ const auditUpdate = auditLogUpdate.entries.filter((entry) => entry.target.channelId === channel.id).first();
+ const auditDelete = auditLogDelete.entries.filter((entry) => entry.target.channelId === channel.id).first();
if (!auditCreate && !auditUpdate && !auditDelete) return;
let audit = auditCreate;
let action = "Create";
@@ -42,10 +25,7 @@
updated: { value: string; displayValue: string };
deleted: { value: string; displayValue: string };
};
- if (
- auditUpdate &&
- auditUpdate.createdTimestamp > audit.createdTimestamp
- ) {
+ if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
const { before, after } = auditUpdate.changes.reduce(
(acc, change) => {
acc.before[change.key] = change.old;
@@ -55,40 +35,21 @@
{ before: {}, after: {} }
);
if (before.name !== after.name)
- list.name = entry(
- [before.name, after.name],
- `${before.name} -> ${after.name}`
- );
+ list.name = entry([before.name, after.name], `${before.name} -> ${after.name}`);
if (before.channel_id !== after.channel_id)
list.channel = entry(
[before.channel_id, after.channel_id],
- renderChannel(
- await client.channels.fetch(before.channel_id)
- ) +
+ renderChannel(await client.channels.fetch(before.channel_id)) +
" -> " +
- renderChannel(
- await client.channels.fetch(after.channel_id)
- )
+ renderChannel(await client.channels.fetch(after.channel_id))
);
if (!Object.keys(list).length) return;
- list.created = entry(
- auditUpdate.target.createdTimestamp,
- renderDelta(auditUpdate.target.createdTimestamp)
- );
- list.edited = entry(
- after.editedTimestamp,
- renderDelta(new Date().getTime())
- );
- list.editedBy = entry(
- auditUpdate.executor.id,
- renderUser(auditUpdate.executor)
- );
+ list.created = entry(auditUpdate.target.createdTimestamp, renderDelta(auditUpdate.target.createdTimestamp));
+ list.edited = entry(after.editedTimestamp, renderDelta(new Date().getTime()));
+ list.editedBy = entry(auditUpdate.executor.id, renderUser(auditUpdate.executor));
audit = auditUpdate;
action = "Update";
- } else if (
- auditDelete &&
- auditDelete.createdTimestamp > audit.createdTimestamp
- ) {
+ } else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
const { before } = auditDelete.changes.reduce(
(acc, change) => {
acc.before[change.key] = change.old;
@@ -99,29 +60,12 @@
);
list = {
name: entry(before.name, `${before.name}`),
- channel: entry(
- before.channel_id,
- renderChannel(
- await client.channels.fetch(before.channel_id)
- )
- ),
- created: entry(
- auditDelete.target.createdTimestamp,
- renderDelta(auditDelete.target.createdTimestamp)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
+ created: entry(auditDelete.target.createdTimestamp, renderDelta(auditDelete.target.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
deletedBy: entry(
auditDelete.executor.id,
- renderUser(
- (
- await channel.guild.members.fetch(
- auditDelete.executor.id
- )
- ).user
- )
+ renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user)
)
};
audit = auditDelete;
@@ -137,26 +81,12 @@
);
list = {
name: entry(before.name, `${before.name}`),
- channel: entry(
- before.channel_id,
- renderChannel(
- await client.channels.fetch(before.channel_id)
- )
- ),
+ channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
createdBy: entry(
auditCreate.executor.id,
- renderUser(
- (
- await channel.guild.members.fetch(
- auditCreate.executor.id
- )
- ).user
- )
+ renderUser((await channel.guild.members.fetch(auditCreate.executor.id)).user)
),
- created: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ created: entry(new Date().getTime(), renderDelta(new Date().getTime()))
};
}
const cols = {
diff --git a/src/index.ts b/src/index.ts
index e40a816..87bbc02 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,9 +1,11 @@
import { Logger } from "./utils/log.js";
import runServer from "./api/index.js";
import Memory from "./utils/memory.js";
+import type { VerifySchema } from "./reflex/verify.js";
import { Guilds, History, ModNotes, Premium } from "./utils/database.js";
import client from "./utils/client.js";
import EventScheduler from "./utils/eventScheduler.js";
+import type { RoleMenuSchema } from "./actions/roleMenu.js";
await client.registerCommandsIn(`dist/commands`);
await client.registerEventsIn(`dist/events`);
@@ -14,17 +16,23 @@
console.error(err);
});
-client.logger = new Logger();
-client.verify = {};
-client.roleMenu = {};
-client.memory = new Memory();
-client.noLog = [];
+client.logger = new Logger() as Logger;
+client.verify = {} as Record<string, VerifySchema>;
+client.roleMenu = {} as Record<string, RoleMenuSchema>;
+client.memory = new Memory() as Memory;
+client.noLog = [] as string[];
client.database = {
guilds: await new Guilds().setup(),
history: await new History().setup(),
notes: await new ModNotes().setup(),
premium: await new Premium().setup(),
eventScheduler: await new EventScheduler().start()
+} as {
+ guilds: Guilds;
+ history: History;
+ notes: ModNotes;
+ premium: Premium;
+ eventScheduler: EventScheduler;
};
await client.login();
diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index 899cd25..0c491b7 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -6,11 +6,8 @@
import addPlural from "../utils/plurals.js";
import type { Message } from "discord.js";
-export default async function logAttachment(
- message: Message
-): Promise<AttachmentLogSchema> {
- if (!message.guild)
- throw new Error("Tried to log an attachment in a non-guild message");
+export default async function logAttachment(message: Message): Promise<AttachmentLogSchema> {
+ if (!message.guild) throw new Error("Tried to log an attachment in a non-guild message");
const { renderUser, renderChannel, renderDelta } = client.logger;
const attachments = [];
for (const attachment of message.attachments.values()) {
@@ -24,11 +21,7 @@
}
const links = message.content.match(/https?:\/\/\S+/gi) ?? [];
for (const link of links) {
- if (
- link
- .toLowerCase()
- .match(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/gi)
- ) {
+ if (link.toLowerCase().match(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/gi)) {
attachments.push({
local: await saveAttachment(link),
url: link,
@@ -39,8 +32,7 @@
}
if (attachments.length === 0) return { files: [] };
if (client.database.premium.hasPremium(message.guild.id)) {
- const channel = (await client.database.guilds.read(message.guild.id))
- .logging.attachments.channel;
+ const channel = (await client.database.guilds.read(message.guild.id)).logging.attachments.channel;
if (!channel) {
singleNotify(
"noAttachmentLogChannel",
@@ -63,17 +55,13 @@
const m = await channelObj.send({
embeds: [
new EmojiEmbed()
- .setTitle(
- `${addPlural(attachments.length, "Attachment")} Sent`
- )
+ .setTitle(`${addPlural(attachments.length, "Attachment")} Sent`)
.setDescription(
keyValueList({
messageId: `\`${message.id}\``,
sentBy: renderUser(message.author),
sentIn: renderChannel(message.channel),
- sent: renderDelta(
- new Date(message.createdTimestamp)
- )
+ sent: renderDelta(new Date(message.createdTimestamp))
}) + `\n[[Jump to message]](${message.url})`
)
.setEmoji("ICONS.ATTACHMENT")
@@ -83,8 +71,7 @@
});
// await client.database.guilds.write(interaction.guild.id, {[`tags.${name}`]: value});
client.database.guilds.write(message.guild.id, {
- [`logging.attachments.saved.${message.channel.id}${message.id}`]:
- m.url
+ [`logging.attachments.saved.${message.channel.id}${message.id}`]: m.url
});
return { files: attachments, jump: m.url };
} else {
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index 3d7f4c6..5fbb8ad 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -1,4 +1,12 @@
-import { MessageActionRow, MessageButton, TextChannel } from "discord.js";
+import {
+ CommandInteraction,
+ DMChannel,
+ Message,
+ MessageActionRow,
+ MessageButton,
+ PartialGroupDMChannel,
+ TextChannel
+} from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
@@ -7,35 +15,28 @@
const pbClient = new PasteClient(config.pastebinApiKey);
-export default async function (interaction) {
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- client.logger;
+export default async function (interaction: CommandInteraction) {
+ if (interaction.channel === null) return;
+ if (interaction.channel instanceof DMChannel) return;
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- let messages = [];
- let deleted = 100;
+ let messages: Message[] = [];
+ let deletedCount: number;
- while (deleted === 100) {
- let fetched;
- await (interaction.channel as TextChannel).messages
- .fetch({ limit: 100 })
- .then(async (ms) => {
- fetched = await (interaction.channel as TextChannel).bulkDelete(
- ms,
- true
- );
- });
- deleted = fetched.size;
- if (fetched) {
- messages = messages.concat(fetched.map((m) => m));
- }
- }
+ do {
+ const fetched = await (interaction.channel as TextChannel).messages.fetch({ limit: 100 });
+ const deleted = await (interaction.channel as TextChannel).bulkDelete(fetched, true);
+ deletedCount = deleted.size;
+ messages = messages.concat(Array.from(deleted.values()));
+ } while (deletedCount === 100);
+
let out = "";
messages.reverse().forEach((message) => {
if (!message.author.bot) {
const sentDate = new Date(message.createdTimestamp);
- out += `${message.author.username}#${
- message.author.discriminator
- } (${message.author.id}) [${sentDate.toUTCString()}]\n`;
+ out += `${message.author.username}#${message.author.discriminator} (${
+ message.author.id
+ }) [${sentDate.toUTCString()}]\n`;
const lines = message.content.split("\n");
lines.forEach((line) => {
out += `> ${line}\n`;
@@ -43,24 +44,18 @@
out += "\n\n";
}
});
- const member = interaction.channel.guild.members.cache.get(
- interaction.channel.topic.split(" ")[0]
- );
+ const member = interaction.channel.guild.members.cache.get(interaction.channel.topic.split(" ")[0]);
let m;
if (out !== "") {
const url = await pbClient.createPaste({
code: out,
expireDate: ExpireDate.Never,
- name: `Ticket Transcript for ${member.user.username}#${
- member.user.discriminator
- } (Created at ${new Date(
+ name: `Ticket Transcript for ${member.user.username}#${member.user.discriminator} (Created at ${new Date(
interaction.channel.createdTimestamp
).toDateString()})`,
publicity: Publicity.Unlisted
});
- const guildConfig = await client.database.guilds.read(
- interaction.guild.id
- );
+ const guildConfig = await client.database.guilds.read(interaction.guild.id);
m = await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -76,10 +71,7 @@
],
components: [
new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("View")
- .setStyle("LINK")
- .setURL(url),
+ new MessageButton().setLabel("View").setStyle("LINK").setURL(url),
new MessageButton()
.setLabel("Delete")
.setStyle("DANGER")
@@ -131,22 +123,10 @@
list: {
ticketFor: entry(
interaction.channel.topic.split(" ")[0],
- renderUser(
- (
- await interaction.guild.members.fetch(
- interaction.channel.topic.split(" ")[0]
- )
- ).user
- )
+ renderUser((await interaction.guild.members.fetch(interaction.channel.topic.split(" ")[0])).user)
),
- deletedBy: entry(
- interaction.member.user.id,
- renderUser(interaction.member.user)
- ),
- deleted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- )
+ deletedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {
guild: interaction.guild.id
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 0b09f69..849c880 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -29,17 +29,13 @@
}
export default async (guild, interaction?) => {
- let c = guild.publicUpdatesChannel
- ? guild.publicUpdatesChannel
- : guild.systemChannel;
+ let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
c = c
? c
: guild.channels.cache.find(
(ch) =>
ch.type === "GUILD_TEXT" &&
- ch
- .permissionsFor(guild.roles.everyone)
- .has("SEND_MESSAGES") &&
+ ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") &&
ch.permissionsFor(guild.me).has("EMBED_LINKS")
);
const pages = [
@@ -96,18 +92,14 @@
`**${getEmojiByName(
"PUNISH.MUTE.GREEN"
)} Unmute:** The user is able to send messages in the server.\n` +
- `**${getEmojiByName(
- "PUNISH.KICK.RED"
- )} Kick:** The user is removed from the server.\n` +
+ `**${getEmojiByName("PUNISH.KICK.RED")} Kick:** The user is removed from the server.\n` +
`**${getEmojiByName(
"PUNISH.SOFTBAN"
)} Softban:** Kicks the user, deleting their messages from every channel.\n` +
`**${getEmojiByName(
"PUNISH.BAN.RED"
)} Ban:** The user is removed from the server, and they are unable to rejoin.\n` +
- `**${getEmojiByName(
- "PUNISH.BAN.GREEN"
- )} Unban:** The user is able to rejoin the server.`
+ `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.`
)
.setEmoji("PUNISH.BAN.RED")
.setStatus("Danger")
@@ -209,9 +201,7 @@
let page = 0;
const f = async (component) => {
- return (component.member as Discord.GuildMember).permissions.has(
- "MANAGE_GUILD"
- );
+ return (component.member as Discord.GuildMember).permissions.has("MANAGE_GUILD");
};
let selectPaneOpen = false;
@@ -261,22 +251,14 @@
]);
if (interaction) {
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: components
});
} else {
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 m.edit({
embeds: [em],
components: components,
@@ -311,11 +293,7 @@
} else {
if (interaction) {
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));
em.setFooter({ text: "Message closed" });
interaction.editReply({
embeds: [em],
@@ -329,9 +307,7 @@
new MessageButton()
.setCustomId("select")
.setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle(
- selectPaneOpen ? "PRIMARY" : "SECONDARY"
- )
+ .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
.setDisabled(true),
new MessageButton()
.setCustomId("right")
@@ -349,9 +325,9 @@
}
if (interaction) {
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(
- em.description + "\n\n" + createPageIndicator(pages.length, page)
- ).setFooter({ text: "Message timed out" });
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
+ text: "Message timed out"
+ });
await interaction.editReply({
embeds: [em],
components: [
@@ -376,9 +352,9 @@
});
} else {
const em = new Discord.MessageEmbed(pages[page].embed);
- em.setDescription(
- em.description + "\n\n" + createPageIndicator(pages.length, page)
- ).setFooter({ text: "Message timed out" });
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
+ text: "Message timed out"
+ });
await m.edit({
embeds: [em],
components: [
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index 2f6f526..bd60f54 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -36,11 +36,8 @@
safe: true,
tags: []
};
-export async function testLink(
- link: string
-): Promise<{ safe: boolean; tags: string[] }> {
- const scanned: { safe?: boolean; tags?: string[] } | undefined =
- await us.link.scan(link);
+export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> {
+ const scanned: { safe?: boolean; tags?: string[] } | undefined = await us.link.scan(link);
if (scanned === undefined) return defaultLinkTestResult;
return {
safe: scanned.safe ?? defaultLinkTestResult.safe,
@@ -53,19 +50,15 @@
DATING: "Dating sites.",
TRACKERS: "Websites that store or track personal information.",
ADVERTISEMENTS: "Websites only for ads.",
- FACEBOOK:
- "Facebook pages. (Facebook has a number of dangerous trackers. Read more on /privacy)",
+ FACEBOOK: "Facebook pages. (Facebook has a number of dangerous trackers. Read more on /privacy)",
AMP: "AMP pages. (AMP is a technology that allows websites to be served by Google. Read more on /privacy)",
"FACEBOOK TRACKERS": "Websites that include trackers from Facebook.",
- "IP GRABBERS":
- "Websites that store your IP address, which shows your approximate location.",
+ "IP GRABBERS": "Websites that store your IP address, which shows your approximate location.",
PORN: "Websites that include pornography.",
GAMBLING: "Gambling sites, often scams.",
- MALWARE:
- "Websites which download files designed to break or slow down your device.",
+ MALWARE: "Websites which download files designed to break or slow down your device.",
PIRACY: "Sites which include illegally downloaded material.",
- RANSOMWARE:
- "Websites which download a program that can steal your data and make you pay to get it back.",
+ RANSOMWARE: "Websites which download a program that can steal your data and make you pay to get it back.",
REDIRECTS: "Sites like bit.ly which could redirect to a malicious site.",
SCAMS: "Sites which are designed to trick you into doing something.",
TORRENT: "Websites that download torrent files.",
@@ -83,12 +76,7 @@
const promises: Promise<void>[] = links.map(async (element) => {
let returned;
try {
- if (
- element.match(
- /https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/
- )
- )
- return; // Also matches discord.net, not enough of a bug
+ if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return; // Also matches discord.net, not enough of a bug
returned = await testLink(element);
} catch {
detections.push({ tags: [], safe: true });
@@ -99,9 +87,7 @@
await Promise.all(promises);
const detectionsTypes = detections
.map((element) => {
- const type = Object.keys(linkTypes).find((type) =>
- element.tags.includes(type)
- );
+ const type = Object.keys(linkTypes).find((type) => element.tags.includes(type));
if (type) return type;
// if (!element.safe) return "UNSAFE"
return undefined;
@@ -119,10 +105,7 @@
}
}
-export async function SizeCheck(element: {
- height: number | null;
- width: number | null;
-}): Promise<boolean> {
+export async function SizeCheck(element: { height: number | null; width: number | null }): Promise<boolean> {
if (element.height === null || element.width === null) return true;
if (element.height < 20 || element.width < 20) return false;
return true;
@@ -136,11 +119,7 @@
}
}
-export function TestString(
- string: string,
- soft: string[],
- strict: string[]
-): object | null {
+export function TestString(string: string, soft: string[], strict: string[]): object | null {
for (const word of strict) {
if (string.toLowerCase().includes(word)) {
return { word: word, type: "strict" };
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 2dee385..a331537 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -14,13 +14,7 @@
if ((props as PropSchema).enabled) {
let string = (props as PropSchema).name;
if (!string) return;
- string = await convertCurlyBracketString(
- string,
- member.id,
- member.displayName,
- guild.name,
- guild.members
- );
+ string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members);
let fetchedChannel;
try {
fetchedChannel = await guild.channels.fetch(channel);
@@ -31,11 +25,7 @@
const deleted = config.getKey("stats")[channel];
console.log(`stats.${channel}`);
console.log(guild.id);
- await client.database.guilds.write(
- guild.id,
- null,
- `stats.${channel}`
- );
+ await client.database.guilds.write(guild.id, null, `stats.${channel}`);
return singleNotify(
"statsChannelDeleted",
guild.id,
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 1737387..c366c8b 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,11 +1,22 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, Interaction } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import fetch from "node-fetch";
import { TestString, NSFWCheck } from "./scanners.js";
import createPageIndicator from "../utils/createPageIndicator.js";
import client from "../utils/client.js";
+export interface VerifySchema {
+ uID: string;
+ gID: string;
+ rID: string;
+ rName: string;
+ uName: string;
+ gName: string;
+ gIcon: string;
+ interaction: Interaction;
+}
+
function step(i: number) {
return "\n\n" + createPageIndicator(5, i);
}
@@ -35,17 +46,12 @@
ephemeral: true,
fetchReply: true
});
- if (
- (interaction.member as GuildMember).roles.cache.has(config.verify.role)
- ) {
+ if ((interaction.member as GuildMember).roles.cache.has(config.verify.role)) {
return await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Verify")
- .setDescription(
- `You already have the <@&${config.verify.role}> role` +
- step(0)
- )
+ .setDescription(`You already have the <@&${config.verify.role}> role` + step(0))
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
]
@@ -61,18 +67,13 @@
]
});
try {
- const status = await fetch(client.config.baseUrl).then(
- (res) => res.status
- );
+ const status = await fetch(client.config.baseUrl).then((res) => res.status);
if (status !== 200) {
return await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Verify")
- .setDescription(
- "Our servers appear to be down, please try again later" +
- step(0)
- )
+ .setDescription("Our servers appear to be down, please try again later" + step(0))
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
]
@@ -83,10 +84,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify")
- .setDescription(
- "Our servers appear to be down, please try again later" +
- step(0)
- )
+ .setDescription("Our servers appear to be down, please try again later" + step(0))
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
],
@@ -109,9 +107,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify")
- .setDescription(
- "Checking your avatar is safe for work" + step(1)
- )
+ .setDescription("Checking your avatar is safe for work" + step(1))
.setStatus("Warning")
.setEmoji("NUCLEUS.LOADING")
]
@@ -180,8 +176,7 @@
let code = "";
let length = 5;
let itt = 0;
- const chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
while (true) {
itt += 1;
code = "";
@@ -210,10 +205,7 @@
embeds: [
new EmojiEmbed()
.setTitle("Verify")
- .setDescription(
- "Looking good!\nClick the button below to get verified" +
- step(4)
- )
+ .setDescription("Looking good!\nClick the button below to get verified" + step(4))
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
],
@@ -222,9 +214,7 @@
new Discord.MessageButton()
.setLabel("Verify")
.setStyle("LINK")
- .setURL(
- `${client.config.baseUrl}nucleus/verify?code=${code}`
- )
+ .setURL(`${client.config.baseUrl}nucleus/verify?code=${code}`)
])
]
});
diff --git a/src/reflex/welcome.ts b/src/reflex/welcome.ts
index 4971cc9..56391ec 100644
--- a/src/reflex/welcome.ts
+++ b/src/reflex/welcome.ts
@@ -19,29 +19,16 @@
);
if (config.welcome.channel === "dm") {
await member.send({
- embeds: [
- new EmojiEmbed()
- .setDescription(string)
- .setStatus("Success")
- ]
+ embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")]
});
} else {
- const channel = await member.guild.channels.fetch(
- config.welcome.channel
- );
+ const channel = await member.guild.channels.fetch(config.welcome.channel);
if (channel.guild.id !== member.guild.id) return;
if (!channel) return;
try {
await channel.send({
- embeds: [
- new EmojiEmbed()
- .setDescription(string)
- .setStatus("Success")
- ],
- content:
- (config.welcome.ping
- ? `<@${config.welcome.ping}>`
- : "") + `<@${member.id}>`
+ embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")],
+ content: (config.welcome.ping ? `<@${config.welcome.ping}>` : "") + `<@${member.id}>`
});
} catch (err) {
console.error(err); // TODO: SEN
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 6d0c55f..6bbbe2e 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -21,14 +21,7 @@
"ticketUpdate"
];
-const tickets = [
- "support",
- "report",
- "question",
- "issue",
- "suggestion",
- "other"
-];
+const tickets = ["support", "report", "question", "issue", "suggestion", "other"];
const toHexInteger = (permissions, array?) => {
if (!array) {
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 728cc52..a8c7ab4 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -1,8 +1,11 @@
import Discord, {
CommandInteraction,
+ Interaction,
Message,
MessageActionRow,
MessageButton,
+ MessageComponentInteraction,
+ ModalSubmitInteraction,
TextInputComponent
} from "discord.js";
import { modalInteractionCollector } from "./dualCollector.js";
@@ -77,7 +80,12 @@
this.reason = reason;
return this;
}
- async send(editOnly?: boolean) {
+ async send(editOnly?: boolean): Promise<{
+ success?: boolean;
+ cancelled?: boolean;
+ components?: Record<string, CustomBoolean<unknown>>;
+ newReason?: string;
+ }> {
while (true) {
const fullComponents = [
new Discord.MessageButton()
@@ -97,8 +105,7 @@
.setLabel(v.title)
.setStyle(v.active ? "SUCCESS" : "PRIMARY")
.setDisabled(v.disabled);
- if (v.emoji !== undefined)
- button.setEmoji(getEmojiByName(v.emoji, "id"));
+ if (v.emoji !== undefined) button.setEmoji(getEmojiByName(v.emoji, "id"));
fullComponents.push(button);
});
if (this.reason !== null)
@@ -112,11 +119,7 @@
);
const components = [];
for (let i = 0; i < fullComponents.length; i += 5) {
- components.push(
- new MessageActionRow().addComponents(
- fullComponents.slice(i, i + 5)
- )
- );
+ components.push(new MessageActionRow().addComponents(fullComponents.slice(i, i + 5)));
}
const object = {
embeds: [
@@ -144,9 +147,7 @@
if (editOnly) {
m = (await this.interaction.editReply(object)) as Message;
} else {
- m = (await this.interaction.reply(
- object
- )) as unknown as Message;
+ m = (await this.interaction.reply(object)) as unknown as Message;
}
} catch {
return { cancelled: true };
@@ -196,9 +197,7 @@
embeds: [
new EmojiEmbed()
.setTitle(this.title)
- .setDescription(
- "Modal opened. If you can't see it, click back and try again."
- )
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus(this.color)
.setEmoji(this.emoji)
],
@@ -216,23 +215,27 @@
try {
out = await modalInteractionCollector(
m,
- (m) => m.channel.id === this.interaction.channel.id,
+ (m: Interaction) =>
+ (m as MessageComponentInteraction | ModalSubmitInteraction).channelId ===
+ this.interaction.channelId,
(m) => m.customId === "reason"
);
} catch (e) {
- return {};
+ return { cancelled: true };
}
- if (out.fields) {
+ if (out === null) {
+ return { cancelled: true };
+ }
+ if (out instanceof ModalSubmitInteraction) {
return {
- newReason: out.fields.getTextInputValue("reason") ?? ""
+ newReason: out.fields.getTextInputValue("reason")
};
} else {
- return { newReason: this.reason };
+ return { components: this.customButtons };
}
} else {
component.deferUpdate();
- this.customButtons[component.customId].active =
- !this.customButtons[component.customId].active;
+ this.customButtons[component.customId]!.active = !this.customButtons[component.customId]!.active;
return { components: this.customButtons };
}
}
diff --git a/src/utils/convertCurlyBracketString.ts b/src/utils/convertCurlyBracketString.ts
index 49a4418..53c3267 100644
--- a/src/utils/convertCurlyBracketString.ts
+++ b/src/utils/convertCurlyBracketString.ts
@@ -1,33 +1,13 @@
-async function convertCurlyBracketString(
- str,
- memberID,
- memberName,
- serverName,
- members
-): Promise<string> {
+async function convertCurlyBracketString(str, memberID, memberName, serverName, members): Promise<string> {
const memberCount = (await members.fetch()).size;
const bots = (await members.fetch()).filter((m) => m.user.bot).size;
str = str
- .replace(
- "{member:mention}",
- memberID ? `<@${memberID}>` : "{member:mention}"
- )
- .replace(
- "{member:name}",
- memberName ? `${memberName}` : "{member:name}"
- )
+ .replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}")
+ .replace("{member:name}", memberName ? `${memberName}` : "{member:name}")
.replace("{serverName}", serverName ? `${serverName}` : "{serverName}")
- .replace(
- "{memberCount}",
- memberCount ? `${memberCount}` : "{memberCount}"
- )
+ .replace("{memberCount}", memberCount ? `${memberCount}` : "{memberCount}")
.replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}")
- .replace(
- "{memberCount:humans}",
- memberCount && bots
- ? `${memberCount - bots}`
- : "{memberCount:humans}"
- );
+ .replace("{memberCount:humans}", memberCount && bots ? `${memberCount - bots}` : "{memberCount:humans}");
return str;
}
diff --git a/src/utils/createPageIndicator.ts b/src/utils/createPageIndicator.ts
index ccf18e2..ee123d6 100644
--- a/src/utils/createPageIndicator.ts
+++ b/src/utils/createPageIndicator.ts
@@ -1,16 +1,10 @@
import getEmojiByName from "./getEmojiByName.js";
-function pageIndicator(
- amount: number,
- selected: number,
- showDetails?: boolean | true
-) {
+function pageIndicator(amount: number, selected: number, showDetails?: boolean | true) {
let out = "";
if (amount === 1) {
- out += getEmojiByName(
- "TRACKS.SINGLE." + (selected === 0 ? "ACTIVE" : "INACTIVE")
- );
+ out += getEmojiByName("TRACKS.SINGLE." + (selected === 0 ? "ACTIVE" : "INACTIVE"));
} else {
for (let i = 0; i < amount; i++) {
out += getEmojiByName(
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 140dbcc..04c9e24 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -17,16 +17,9 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get(target: Record<string, any>, prop: string, receiver: any) {
let dataToReturn = data[prop];
- if (dataToReturn === null)
- return Reflect.get(target, prop, receiver);
- if (
- typeof dataToReturn === "object" &&
- !Array.isArray(dataToReturn)
- )
- dataToReturn = new Proxy(
- Reflect.get(target, prop, receiver),
- Entry(dataToReturn)
- );
+ if (dataToReturn === null) return Reflect.get(target, prop, receiver);
+ if (typeof dataToReturn === "object" && !Array.isArray(dataToReturn))
+ dataToReturn = new Proxy(Reflect.get(target, prop, receiver), Entry(dataToReturn));
return dataToReturn ?? Reflect.get(target, prop, receiver);
}
};
@@ -43,24 +36,17 @@
}
async setup() {
- this.defaultData = (
- await import("../config/default.json", { assert: { type: "json" } })
- ).default as unknown as GuildConfig;
+ this.defaultData = (await import("../config/default.json", { assert: { type: "json" } }))
+ .default as unknown as GuildConfig;
+ return this;
}
async read(guild: string) {
const entry = await this.guilds.findOne({ id: guild });
- return new Proxy(
- structuredClone(this.defaultData),
- Entry(entry)
- ) as unknown as GuildConfig;
+ return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig;
}
- async write(
- guild: string,
- set: object | null,
- unset: string[] | string = []
- ) {
+ async write(guild: string, set: object | null, unset: string[] | string = []) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const uo: Record<string, any> = {};
if (!Array.isArray(unset)) unset = [unset];
@@ -195,11 +181,7 @@
}
async create(guild: string, user: string, note: string | null) {
- await this.modNotes.updateOne(
- { guild: guild, user: user },
- { $set: { note: note } },
- { upsert: true }
- );
+ await this.modNotes.updateOne({ guild: guild, user: user }, { $set: { note: note } }, { upsert: true });
}
async read(guild: string, user: string) {
diff --git a/src/utils/defaultEmbeds.ts b/src/utils/defaultEmbeds.ts
index 68d8013..2200a5e 100644
--- a/src/utils/defaultEmbeds.ts
+++ b/src/utils/defaultEmbeds.ts
@@ -1,9 +1,5 @@
import EmojiEmbed from "./generateEmojiEmbed.js";
export const LoadingEmbed = [
- new EmojiEmbed()
- .setTitle("Loading")
- .setDescription("One moment...")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
+ new EmojiEmbed().setTitle("Loading").setDescription("One moment...").setStatus("Danger").setEmoji("NUCLEUS.LOADING")
];
diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts
index 8c6e55c..abc6bb3 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -1,15 +1,9 @@
-import Discord, {
- Interaction,
- Message,
- MessageComponentInteraction
-} from "discord.js";
+import Discord, { Interaction, Message, MessageComponentInteraction } from "discord.js";
import client from "./client.js";
export default async function (
m: Message,
- interactionFilter: (
- i: MessageComponentInteraction
- ) => boolean | Promise<boolean>,
+ interactionFilter: (i: MessageComponentInteraction) => boolean | Promise<boolean>,
messageFilter: (m: Message) => boolean | Promise<boolean>
) {
let out;
@@ -54,17 +48,14 @@
export async function modalInteractionCollector(
m: Message,
modalFilter: (i: Interaction) => boolean | Promise<boolean>,
- interactionFilter: (
- i: MessageComponentInteraction
- ) => boolean | Promise<boolean>
-) {
- let out;
+ interactionFilter: (i: MessageComponentInteraction) => boolean | Promise<boolean>
+): Promise<null | Interaction> {
+ let out: Interaction;
try {
out = await new Promise((resolve, _reject) => {
const int = m
.createMessageComponentCollector({
- filter: (i: MessageComponentInteraction) =>
- interactionFilter(i),
+ filter: (i: MessageComponentInteraction) => interactionFilter(i),
time: 300000
})
.on("collect", (i: Interaction) => {
diff --git a/src/utils/eventScheduler.ts b/src/utils/eventScheduler.ts
index 6923ede..203e05b 100644
--- a/src/utils/eventScheduler.ts
+++ b/src/utils/eventScheduler.ts
@@ -23,28 +23,16 @@
await job.remove();
});
this.agenda.define("deleteFile", async (job) => {
- fs.rm(
- path.resolve("dist/utils/temp", job.attrs.data.fileName),
- client._error
- );
+ fs.rm(path.resolve("dist/utils/temp", job.attrs.data.fileName), client._error);
await job.remove();
});
this.agenda.define("naturalUnmute", async (job) => {
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const guild = await client.guilds.fetch(job.attrs.data.guild);
const user = await guild.members.fetch(job.attrs.data.user);
if (user.communicationDisabledUntil === null) return;
try {
- await client.database.history.create(
- "unmute",
- user.guild.id,
- user.user,
- null,
- null,
- null,
- null
- );
+ await client.database.history.create("unmute", user.guild.id, user.user, null, null, null, null);
} catch (e) {
client._error(e);
}
@@ -60,10 +48,7 @@
list: {
memberId: entry(user.user.id, `\`${user.user.id}\``),
name: entry(user.user.id, renderUser(user.user)),
- unmuted: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
+ unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
unmutedBy: entry(null, "*Time out ended*")
},
hidden: {
diff --git a/src/utils/generateKeyValueList.ts b/src/utils/generateKeyValueList.ts
index a158391..54b8d99 100644
--- a/src/utils/generateKeyValueList.ts
+++ b/src/utils/generateKeyValueList.ts
@@ -7,8 +7,7 @@
.map((word) => {
return forceCaps.includes(word.toUpperCase())
? word.toUpperCase()
- : (word[0] ?? "").toUpperCase() +
- word.slice(1).toLowerCase().replace("discord", "Discord");
+ : (word[0] ?? "").toUpperCase() + word.slice(1).toLowerCase().replace("discord", "Discord");
})
.join(" ");
return s;
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 6baa0a5..fdf17ef 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -34,9 +34,7 @@
return `${role.name} [<@&${role.id}>]`;
}
renderEmoji(emoji: Discord.GuildEmoji) {
- return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${
- emoji.name
- }:\`]`;
+ return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
}
public readonly NucleusColors = {
@@ -59,17 +57,11 @@
const config = await client.database.guilds.read(log.hidden.guild);
if (!config.logging.logs.enabled) return;
if (!(log.meta.calculateType === true)) {
- if (
- !toHexArray(config.logging.logs.toLog).includes(
- log.meta.calculateType
- )
- )
+ if (!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType))
return console.log("Not logging this type of event");
}
if (config.logging.logs.channel) {
- const channel = (await client.channels.fetch(
- config.logging.logs.channel
- )) as Discord.TextChannel | null;
+ const channel = (await client.channels.fetch(config.logging.logs.channel)) as Discord.TextChannel | null;
const description: Record<string, string> = {};
Object.entries(log.list).map((entry) => {
const key: string = entry[0];
@@ -84,11 +76,7 @@
if (channel) {
log.separate = log.separate || {};
const embed = new Discord.MessageEmbed()
- .setTitle(
- `${getEmojiByName(log.meta.emoji)} ${
- log.meta.displayName
- }`
- )
+ .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
.setDescription(
(log.separate.start ? log.separate.start + "\n" : "") +
generateKeyValueList(description) +
diff --git a/src/utils/temp/generateFileName.ts b/src/utils/temp/generateFileName.ts
index 956f1d7..8534846 100644
--- a/src/utils/temp/generateFileName.ts
+++ b/src/utils/temp/generateFileName.ts
@@ -12,10 +12,8 @@
if (fs.existsSync(`./${fileName}`)) {
fileName = generateFileName(ending);
}
- client.database.eventScheduler.schedule(
- "deleteFile",
- new Date().getTime() + 60 * 1000,
- { fileName: `${fileName}.${ending}` }
- );
+ client.database.eventScheduler.schedule("deleteFile", new Date().getTime() + 60 * 1000, {
+ fileName: `${fileName}.${ending}`
+ });
return path.join(__dirname, fileName + "." + ending);
}