Reformat using prettier
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index c5fcca5..af8006c 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -5,4 +5,4 @@
const subcommand = await command(name, description, `mod`);
-export { name, description, subcommand as command };
\ No newline at end of file
+export { name, description, subcommand as command };
diff --git a/src/commands/mod/about.ts b/src/commands/mod/about.ts
index 0a9d962..8736054 100644
--- a/src/commands/mod/about.ts
+++ b/src/commands/mod/about.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from '../../utils/defaults.js';
+import { LoadingEmbed } from "../../utils/defaults.js";
import type { HistorySchema } from "../../utils/database.js";
import Discord, {
CommandInteraction,
@@ -104,10 +104,7 @@
let history, current: TimelineSection;
history = await client.database.history.read(member.guild.id, member.id, currentYear);
history = history
- .sort(
- (a: { occurredAt: Date }, b: { occurredAt: Date }) =>
- b.occurredAt.getTime() - a.occurredAt.getTime()
- )
+ .sort((a: { occurredAt: Date }, b: { occurredAt: Date }) => b.occurredAt.getTime() - a.occurredAt.getTime())
.reverse();
let m: Message;
let refresh = false;
@@ -154,59 +151,62 @@
}
}
if (pageIndex === null) pageIndex = 0;
- let components: (ActionRowBuilder<Discord.StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[] = []
- if (openFilterPane) components = components.concat([
- new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
- new Discord.StringSelectMenuBuilder()
- .setMinValues(1)
- .setMaxValues(Object.keys(types).length)
- .setCustomId("filter")
- .setPlaceholder("Select events to show")
- .setOptions(...Object.entries(types).map(([key, value]) => new Discord.StringSelectMenuOptionBuilder()
- .setLabel(value.text)
- .setValue(key)
- .setDefault(filteredTypes.includes(key))
- .setEmoji(getEmojiByName(value.emoji, "id") as APIMessageComponentEmoji)
- )))
+ let components: (ActionRowBuilder<Discord.StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[] = [];
+ if (openFilterPane)
+ components = components.concat([
+ new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
+ new Discord.StringSelectMenuBuilder()
+ .setMinValues(1)
+ .setMaxValues(Object.keys(types).length)
+ .setCustomId("filter")
+ .setPlaceholder("Select events to show")
+ .setOptions(
+ ...Object.entries(types).map(([key, value]) =>
+ new Discord.StringSelectMenuOptionBuilder()
+ .setLabel(value.text)
+ .setValue(key)
+ .setDefault(filteredTypes.includes(key))
+ .setEmoji(getEmojiByName(value.emoji, "id") as APIMessageComponentEmoji)
+ )
+ )
+ )
+ ]);
+ components = components.concat([
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setCustomId("prevYear")
+ .setLabel((currentYear - 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId("prevPage").setLabel("Previous page").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder().setCustomId("today").setLabel("Today").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId("nextPage")
+ .setLabel("Next page")
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ new ButtonBuilder()
+ .setCustomId("nextYear")
+ .setLabel((currentYear + 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(currentYear === new Date().getFullYear())
+ ])
]);
- components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setCustomId("prevYear")
- .setLabel((currentYear - 1).toString())
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId("prevPage")
- .setLabel("Previous page")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("today")
- .setLabel("Today")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("nextPage")
- .setLabel("Next page")
- .setStyle(ButtonStyle.Primary)
- .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
- new ButtonBuilder()
- .setCustomId("nextYear")
- .setLabel((currentYear + 1).toString())
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(currentYear === new Date().getFullYear())
- ])])
- components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setLabel("Mod notes")
- .setCustomId("modNotes")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
- new ButtonBuilder()
- .setLabel("Filter")
- .setCustomId("openFilter")
- .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
- ])])
+ components = components.concat([
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setLabel("Mod notes")
+ .setCustomId("modNotes")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new ButtonBuilder()
+ .setLabel("Filter")
+ .setCustomId("openFilter")
+ .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
+ ])
+ ]);
const end =
"\n\nJanuary " +
@@ -227,7 +227,10 @@
)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : "No filters selected"
})
],
components: components
@@ -241,17 +244,26 @@
.setDescription(`**${currentYear}**\n\n*No events*`)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : "No filters selected"
})
],
components: components
- })
+ });
}
let i: MessageComponentInteraction;
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
interaction.editReply({
@@ -328,7 +340,9 @@
let timedOut = false;
while (!timedOut) {
note = await client.database.notes.read(member.guild.id, member.id);
- if (firstLoad && !note) { await showHistory(member, interaction); }
+ if (firstLoad && !note) {
+ await showHistory(member, interaction);
+ }
firstLoad = false;
m = (await interaction.editReply({
embeds: [
@@ -357,7 +371,13 @@
try {
i = await m.awaitMessageComponent({
time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+ filter: (i) => {
+ return (
+ i.user.id === interaction.user.id &&
+ i.channel!.id === interaction.channel!.id &&
+ i.message.id === m.id
+ );
+ }
});
} catch (e) {
timedOut = true;
@@ -424,13 +444,13 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
return true;
};
export { command, callback, check };
export const metadata = {
- longDescription: "Shows the moderation history (all previous bans, kicks, warns etc.), and moderator notes for a user.",
- premiumOnly: true,
-}
+ longDescription:
+ "Shows the moderation history (all previous bans, kicks, warns etc.), and moderator notes for a user.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index e8309fb..628b607 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,4 +1,12 @@
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle, SlashCommandSubcommandBuilder } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ User,
+ ButtonStyle,
+ SlashCommandSubcommandBuilder
+} from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
@@ -7,7 +15,6 @@
import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("ban")
@@ -22,7 +29,6 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
const { renderUser } = client.logger;
@@ -39,12 +45,13 @@
.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.get("delete")?.value as number | null) ?? 0, "day")
- } of messages will be deleted\n\n` +
+ (interaction.options.get("delete")?.value as number | null) ?? 0,
+ "day"
+ )} of messages will be deleted\n\n` +
`Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.addCustomBoolean(
@@ -66,15 +73,20 @@
else if (confirmation.success !== undefined) chosen = true;
else if (confirmation.newReason) reason = confirmation.newReason;
else if (confirmation.components) notify = confirmation.components["notify"]!.active;
- } while (!timedOut && !chosen)
+ } while (!timedOut && !chosen);
if (timedOut || !confirmation.success) return;
- reason = reason.length ? reason : null
+ reason = reason.length ? reason : null;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -92,14 +104,20 @@
components: []
};
if (config.moderation.ban.text && config.moderation.ban.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.ban.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -109,7 +127,7 @@
}
try {
const member = interaction.options.getMember("user") as GuildMember;
- const days: number = interaction.options.get("delete")?.value as number | null ?? 0;
+ const days: number = (interaction.options.get("delete")?.value as number | null) ?? 0;
member.ban({
deleteMessageSeconds: days * 24 * 60 * 60,
reason: reason ?? "*No reason provided*"
@@ -135,7 +153,9 @@
serverMemberCount: interaction.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -174,17 +194,17 @@
const member = interaction.member as GuildMember;
// Check if the user has ban_members permission
if (!member.permissions.has("BanMembers")) return "You do not have the *Ban Members* permission";
- if(partial) return true;
+ if (partial) return true;
const me = interaction.guild.members.me!;
let apply = interaction.options.getUser("user") as User | GuildMember;
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
- let applyPos = 0
+ let applyPos = 0;
try {
- apply = await interaction.guild.members.fetch(apply.id) as GuildMember
+ apply = (await interaction.guild.members.fetch(apply.id)) as GuildMember;
applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
} catch {
- apply = apply as User
+ apply = apply as User;
}
// Do not allow banning the owner
if (member.id === interaction.guild.ownerId) return "You cannot ban the owner of the server";
@@ -204,6 +224,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Removes a member from the server - this will prevent them from rejoining until they are unbanned, and will delete a specified number of days of messages from them.",
- premiumOnly: true,
-}
+ longDescription:
+ "Removes a member from the server - this will prevent them from rejoining until they are unbanned, and will delete a specified number of days of messages from them.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 059bdb2..c4f1867 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,5 +1,12 @@
-import { LinkWarningFooter } from '../../utils/defaults.js';
-import { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandSubcommandBuilder } from "discord.js";
+import { LinkWarningFooter } from "../../utils/defaults.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ SlashCommandSubcommandBuilder
+} from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
import type Discord from "discord.js";
@@ -31,9 +38,8 @@
.setDescription(
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
- reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
- }) +
- `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
+ reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
+ }) + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.setColor("Danger")
.addCustomBoolean(
@@ -56,14 +62,19 @@
else if (confirmation.components) {
notify = confirmation.components["notify"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !confirmation.success) return;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -81,14 +92,20 @@
components: []
};
if (config.moderation.kick.text && config.moderation.kick.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.kick.text)
- .setURL(config.moderation.kick.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.kick.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -101,12 +118,14 @@
const member = interaction.options.getMember("user") as GuildMember;
await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const timeInServer = member.joinedTimestamp ? entry(
- (Date.now() - member.joinedTimestamp).toString(),
- humanizeDuration(Date.now() - member.joinedTimestamp, {
- round: true
- })
- ) : entry(null, "*Unknown*")
+ const timeInServer = member.joinedTimestamp
+ ? entry(
+ (Date.now() - member.joinedTimestamp).toString(),
+ humanizeDuration(Date.now() - member.joinedTimestamp, {
+ round: true
+ })
+ )
+ : entry(null, "*Unknown*");
const data = {
meta: {
type: "memberKick",
@@ -119,7 +138,7 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: undefined as (unknown | typeof entry),
+ joined: undefined as unknown | typeof entry,
kicked: entry(Date.now().toString(), renderDelta(Date.now())),
kickedBy: entry(interaction.user.id, renderUser(interaction.user)),
reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
@@ -127,22 +146,18 @@
serverMemberCount: member.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: member.guild.id
}
};
if (member.joinedTimestamp) {
- data.list.joined = entry(member.joinedTimestamp.toString(), renderDelta(member.joinedTimestamp))
+ data.list.joined = entry(member.joinedTimestamp.toString(), renderDelta(member.joinedTimestamp));
}
- await client.database.history.create(
- "kick",
- interaction.guild.id,
- member.user,
- interaction.user,
- reason
- )
+ await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
log(data);
} catch {
await interaction.editReply({
@@ -203,5 +218,5 @@
export { command, callback, check };
export const metadata = {
longDescription: "Removes a member from the server. They will be able to rejoin if they have an invite link.",
- premiumOnly: true,
-}
+ premiumOnly: true
+};
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index c795456..39c9e5e 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -49,12 +49,11 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
- const time: {days: number, hours: number, minutes: number, seconds: number} = {
+ const time: { days: number; hours: number; minutes: number; seconds: number } = {
days: (interaction.options.get("days")?.value as number | null) ?? 0,
hours: (interaction.options.get("hours")?.value as number | null) ?? 0,
minutes: (interaction.options.get("minutes")?.value as number | null) ?? 0,
@@ -79,8 +78,14 @@
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder().setCustomId("1m").setLabel("1 Minute").setStyle(ButtonStyle.Secondary),
- new Discord.ButtonBuilder().setCustomId("10m").setLabel("10 Minutes").setStyle(ButtonStyle.Secondary),
- new Discord.ButtonBuilder().setCustomId("30m").setLabel("30 Minutes").setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("10m")
+ .setLabel("10 Minutes")
+ .setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("30m")
+ .setLabel("30 Minutes")
+ .setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("1h").setLabel("1 Hour").setStyle(ButtonStyle.Secondary)
]),
new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -103,7 +108,9 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => {return i.user.id === interaction.user.id && i.channelId === interaction.channelId},
+ filter: (i) => {
+ return i.user.id === interaction.user.id && i.channelId === interaction.channelId;
+ },
time: 300000
});
} catch {
@@ -178,7 +185,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 +
@@ -190,7 +197,8 @@
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ async () =>
+ await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
null,
"CONTROL.TICKET",
@@ -217,13 +225,22 @@
notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !confirmation.success) return;
- const status: {timeout: boolean | null, role: boolean | null, dm: boolean | null} = {timeout: null, role: null, dm: null};
+ const status: { timeout: boolean | null; role: boolean | null; dm: boolean | null } = {
+ timeout: null,
+ role: null,
+ dm: null
+ };
let dmMessage;
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -234,28 +251,39 @@
.setTitle("Muted")
.setDescription(
`You have been muted in ${interaction.guild.name}` +
- (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") + "\n\n" +
- `You will be unmuted at: <t:${Math.round(Date.now() / 1000) + muteTime}:D> at ` +
- `<t:${Math.round(Date.now() / 1000) + muteTime}:T> (<t:${Math.round(Date.now() / 1000) + muteTime
- }:R>)` + "\n\n" +
- (createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
- : "")
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") +
+ "\n\n" +
+ `You will be unmuted at: <t:${Math.round(Date.now() / 1000) + muteTime}:D> at ` +
+ `<t:${Math.round(Date.now() / 1000) + muteTime}:T> (<t:${
+ Math.round(Date.now() / 1000) + muteTime
+ }:R>)` +
+ "\n\n" +
+ (createAppealTicket
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
+ : "")
)
.setStatus("Danger")
],
components: []
- }
+ };
if (config.moderation.mute.text && config.moderation.mute.link) {
messageData.embeds[0]!.setFooter(LinkWarningFooter);
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
- .setStyle(ButtonStyle.Link)
- .setLabel(config.moderation.mute.text)
- .setURL(config.moderation.mute.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setStyle(ButtonStyle.Link)
+ .setLabel(config.moderation.mute.text)
+ .setURL(
+ config.moderation.mute.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
)
- )
- };
+ );
+ }
dmMessage = await member.send(messageData);
status.dm = true;
}
@@ -267,11 +295,15 @@
await member.timeout(muteTime * 1000, reason || "*No reason provided*");
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("naturalUnmute", (Date.now() + muteTime * 1000).toString(), {
- guild: interaction.guild.id,
- user: member.id,
- expires: Date.now() + muteTime * 1000
- });
+ await client.database.eventScheduler.schedule(
+ "naturalUnmute",
+ (Date.now() + muteTime * 1000).toString(),
+ {
+ guild: interaction.guild.id,
+ user: member.id,
+ expires: Date.now() + muteTime * 1000
+ }
+ );
}
} else {
status.timeout = true;
@@ -293,7 +325,7 @@
} catch {
status.role = false;
}
- const countTrue = (items: (boolean | null)[]) => items.filter(item => item === true).length;
+ const countTrue = (items: (boolean | null)[]) => items.filter((item) => item === true).length;
const requiredPunishments = countTrue([config.moderation.mute.timeout, config.moderation.mute.role !== null]);
const actualPunishments = countTrue([status.timeout, status.role]);
@@ -301,7 +333,8 @@
if (requiredPunishments !== actualPunishments) {
const messages = [];
if (config.moderation.mute.timeout) messages.push(`The member was ${status.timeout ? "" : "not "}timed out`);
- if (config.moderation.mute.role !== null) messages.push(`The member was ${status.role ? "" : "not "}given the mute role`);
+ if (config.moderation.mute.role !== null)
+ messages.push(`The member was ${status.role ? "" : "not "}given the mute role`);
messages.push(`The member was not sent a DM`);
if (dmMessage && actualPunishments === 0) await dmMessage.delete();
await interaction.editReply({
@@ -310,8 +343,10 @@
.setEmoji("PUNISH.MUTE." + (actualPunishments > 0 ? "YELLOW" : "RED"))
.setTitle("Mute")
.setDescription(
- "Mute " + (actualPunishments > 0 ? "partially" : "failed") + ":\n" +
- messages.map(message => `> ${message}`).join("\n")
+ "Mute " +
+ (actualPunishments > 0 ? "partially" : "failed") +
+ ":\n" +
+ messages.map((message) => `> ${message}`).join("\n")
)
.setStatus(actualPunishments > 0 ? "Warning" : "Danger")
],
@@ -330,16 +365,15 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- mutedUntil: entry(
- (Date.now() + muteTime * 1000).toString(),
- renderDelta(Date.now() + muteTime * 1000)
- ),
+ mutedUntil: entry((Date.now() + muteTime * 1000).toString(), renderDelta(Date.now() + muteTime * 1000)),
muted: entry(new Date().getTime.toString(), renderDelta(Date.now() - 1000)),
mutedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
reason: entry(reason, reason ? reason : "*No reason provided*")
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -353,10 +387,11 @@
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle("Mute")
.setDescription(
- "The member was muted" + (failed ? ", but could not be notified" : "") +
- (createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
- : "")
+ "The member was muted" +
+ (failed ? ", but could not be notified" : "") +
+ (createAppealTicket
+ ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ : "")
)
.setStatus(failed ? "Warning" : "Success")
],
@@ -393,6 +428,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Stops a member from being able to send messages or join voice channels for a specified amount of time.",
- premiumOnly: true,
-}
+ longDescription:
+ "Stops a member from being able to send messages or join voice channels for a specified amount of time.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 5511d19..8b33551 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,4 +1,4 @@
-import { LinkWarningFooter } from './../../utils/defaults.js';
+import { LinkWarningFooter } from "./../../utils/defaults.js";
import { ActionRowBuilder, ButtonBuilder, CommandInteraction, GuildMember, ButtonStyle, Message } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -8,15 +8,14 @@
import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
-const command = (builder: SlashCommandSubcommandBuilder) => builder
- .setName("nick")
- .setDescription("Changes a users nickname")
- .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
- .addStringOption((option) =>
- option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
- );
-
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder
+ .setName("nick")
+ .setDescription("Changes a users nickname")
+ .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
+ .addStringOption((option) =>
+ option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
+ );
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
@@ -35,19 +34,27 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
"new nickname": `${
- interaction.options.get("name")?.value as string ? interaction.options.get("name")?.value as string : "*No nickname*"
+ (interaction.options.get("name")?.value as string)
+ ? (interaction.options.get("name")?.value as string)
+ : "*No nickname*"
}`
}) +
- `Are you sure you want to ${interaction.options.get("name")?.value as string ? "change" : "clear"} <@!${
- (interaction.options.getMember("user") as GuildMember).id
- }>'s nickname?`
+ `Are you sure you want to ${
+ (interaction.options.get("name")?.value as string) ? "change" : "clear"
+ } <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`
)
.setColor("Danger")
.addCustomBoolean(
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild!.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, "Nickname changed"),
+ async () =>
+ await create(
+ interaction.guild!,
+ interaction.options.getUser("user")!,
+ interaction.user,
+ "Nickname changed"
+ ),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -69,7 +76,7 @@
if (confirmation.cancelled) timedOut = true;
else if (confirmation.success !== undefined) success = true;
else if (confirmation.components) {
- notify = confirmation.components['notify']!.active;
+ notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
} while (!timedOut && !success);
@@ -88,29 +95,38 @@
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(
- `Your nickname was ${interaction.options.get("name")?.value as string ? "changed" : "cleared"} in ${
- interaction.guild!.name
- }.` +
- (interaction.options.get("name")?.value as string
+ `Your nickname was ${
+ (interaction.options.get("name")?.value as string) ? "changed" : "cleared"
+ } in ${interaction.guild!.name}.` +
+ ((interaction.options.get("name")?.value as string)
? `\nIt is now: ${interaction.options.get("name")?.value as string}`
: "") +
"\n\n" +
(createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Danger")
- ], components: []
+ ],
+ components: []
};
if (config.moderation.nick.text && config.moderation.nick.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.nick.text)
- .setURL(config.moderation.nick.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.nick.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -166,7 +182,9 @@
updatedBy: entry(interaction.user.id, renderUser(interaction.user))
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild!.id
@@ -221,6 +239,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Changes the nickname of a member. This is the name that shows in the member list and on messages.",
- premiumOnly: true,
-}
+ longDescription:
+ "Changes the nickname of a member. This is the name that shows in the member list and on messages.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index a1b094e..2c8129e 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,12 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle, ButtonBuilder, Message } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildChannel,
+ GuildMember,
+ TextChannel,
+ ButtonStyle,
+ ButtonBuilder,
+ Message
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -27,7 +35,7 @@
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return;
- const user = (interaction.options.getMember("user") as GuildMember | null);
+ const user = interaction.options.getMember("user") as GuildMember | null;
const channel = interaction.channel as GuildChannel;
if (!channel.isTextBased()) {
return await interaction.reply({
@@ -93,7 +101,8 @@
let component;
try {
component = m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch (e) {
@@ -112,7 +121,7 @@
if (user) {
ms = ms.filter((m) => m.author.id === user.id);
}
- messages = (await (channel as TextChannel).bulkDelete(ms, true)).map(m => m as Discord.Message);
+ messages = (await (channel as TextChannel).bulkDelete(ms, true)).map((m) => m as Discord.Message);
});
deleted = deleted.concat(messages);
}
@@ -133,7 +142,7 @@
interaction.guild.id,
user.user,
interaction.user,
- (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
+ (interaction.options.get("reason")?.value as string | null) ?? "*No reason provided*",
null,
null,
deleted.length.toString()
@@ -160,7 +169,11 @@
}
};
log(data);
- const newOut = await client.database.transcripts.createTranscript(deleted, interaction, interaction.member as GuildMember);
+ const newOut = await client.database.transcripts.createTranscript(
+ deleted,
+ interaction,
+ interaction.member as GuildMember
+ );
const transcript = client.database.transcripts.toHumanReadable(newOut);
const attachmentObject = {
attachment: Buffer.from(transcript),
@@ -188,7 +201,8 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch {
@@ -227,7 +241,11 @@
keyValueList({
channel: `<#${channel.id}>`,
amount: (interaction.options.get("amount")?.value as number).toString(),
- reason: `\n> ${interaction.options.get("reason")?.value ? interaction.options.get("reason")?.value : "*No reason provided*"}`
+ reason: `\n> ${
+ interaction.options.get("reason")?.value
+ ? interaction.options.get("reason")?.value
+ : "*No reason provided*"
+ }`
})
)
.setColor("Danger")
@@ -282,7 +300,7 @@
interaction.guild.id,
user.user,
interaction.user,
- (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
+ (interaction.options.get("reason")?.value as string | null) ?? "*No reason provided*",
null,
null,
messages.size.toString()
@@ -309,14 +327,19 @@
}
};
log(data);
- const messageArray: Message[] = messages.filter(message => !(
- message!.components.some(
- component => component.components.some(
- child => child.customId?.includes("transcript") ?? false
- )
+ const messageArray: Message[] = messages
+ .filter(
+ (message) =>
+ !message!.components.some((component) =>
+ component.components.some((child) => child.customId?.includes("transcript") ?? false)
+ )
)
- )).map(message => message as Message);
- const newOut = await client.database.transcripts.createTranscript(messageArray, interaction, interaction.member as GuildMember);
+ .map((message) => message as Message);
+ const newOut = await client.database.transcripts.createTranscript(
+ messageArray,
+ interaction,
+ interaction.member as GuildMember
+ );
const [code, key, iv] = await client.database.transcripts.create(newOut);
@@ -330,8 +353,11 @@
],
components: [
new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`).setDisabled(!code),
-
+ new ButtonBuilder()
+ .setLabel("View")
+ .setStyle(ButtonStyle.Link)
+ .setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`)
+ .setDisabled(!code)
])
]
});
@@ -355,6 +381,7 @@
export { command, callback, check };
export const metadata = {
- longDescription: "Deletes a specified amount of messages from a channel, optionally from a specific user. Without an amount, you can repeatedly choose a number of messages to delete.",
- premiumOnly: true,
-}
+ longDescription:
+ "Deletes a specified amount of messages from a channel, optionally from a specific user. Without an amount, you can repeatedly choose a number of messages to delete.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index f282e82..ba88c00 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -16,25 +16,25 @@
.setDescription("The delay between messages")
.setRequired(false)
.addChoices(
- {name: "Off", value: "0"},
- {name: "5 seconds", value: "5"},
- {name: "10 seconds", value: "10"},
- {name: "15 seconds", value: "15"},
- {name: "30 seconds", value: "30"},
- {name: "1 minute", value: "60"},
- {name: "2 minutes", value: "120"},
- {name: "5 minutes", value: "300"},
- {name: "10 minutes", value: "600"},
- {name: "15 minutes", value: "900"},
- {name: "30 minutes", value: "1800"},
- {name: "1 hour", value: "3600"},
- {name: "2 hours", value: "7200"},
- {name: "6 hours", value: "21600"}
+ { name: "Off", value: "0" },
+ { name: "5 seconds", value: "5" },
+ { name: "10 seconds", value: "10" },
+ { name: "15 seconds", value: "15" },
+ { name: "30 seconds", value: "30" },
+ { name: "1 minute", value: "60" },
+ { name: "2 minutes", value: "120" },
+ { name: "5 minutes", value: "300" },
+ { name: "10 minutes", value: "600" },
+ { name: "15 minutes", value: "900" },
+ { name: "30 minutes", value: "1800" },
+ { name: "1 hour", value: "3600" },
+ { name: "2 hours", value: "7200" },
+ { name: "6 hours", value: "21600" }
)
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
- let time = parseInt(interaction.options.get("time")?.value as string || "0");
+ let time = parseInt((interaction.options.get("time")?.value as string) || "0");
if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) {
time = 10;
}
@@ -82,13 +82,15 @@
if (!member.permissions.has("ManageChannels")) return "You do not have the *Manage Channels* permission";
if (partial) return true;
// Check if Nucleus can set the slowmode
- if (!interaction.guild!.members.me!.permissions.has("ManageChannels")) return "I do not have the *Manage Channels* permission";
+ if (!interaction.guild!.members.me!.permissions.has("ManageChannels"))
+ return "I do not have the *Manage Channels* permission";
// Allow slowmode
return true;
};
export { command, callback, check };
export const metadata = {
- longDescription: "Stops members from being able to send messages without waiting a certain amount of time between messages.",
- premiumOnly: true,
-}
+ longDescription:
+ "Stops members from being able to send messages without waiting a certain amount of time between messages.",
+ premiumOnly: true
+};
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 1b404c9..cd03d1a 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,4 +1,11 @@
-import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ ActionRowBuilder,
+ ButtonBuilder,
+ User,
+ ButtonStyle
+} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -8,7 +15,6 @@
import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("softban")
@@ -23,7 +29,6 @@
.setRequired(false)
);
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!interaction.guild) return;
const { renderUser } = client.logger;
@@ -40,12 +45,13 @@
.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.get("delete")?.value as number | null) ?? 0, "day")
- } of messages will be deleted\n\n` +
+ (interaction.options.get("delete")?.value as number | null) ?? 0,
+ "day"
+ )} of messages will be deleted\n\n` +
`Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.addCustomBoolean(
@@ -67,15 +73,20 @@
else if (confirmation.success !== undefined) chosen = true;
else if (confirmation.newReason) reason = confirmation.newReason;
else if (confirmation.components) notify = confirmation.components["notify"]!.active;
- } while (!timedOut && !chosen)
+ } while (!timedOut && !chosen);
if (timedOut || !confirmation.success) return;
- reason = reason.length ? reason : null
+ reason = reason.length ? reason : null;
let dmSent = false;
let dmMessage;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -93,14 +104,20 @@
components: []
};
if (config.moderation.softban.text && config.moderation.softban.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.softban.text)
- .setURL(config.moderation.softban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.softban.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -110,7 +127,7 @@
}
try {
const member = interaction.options.getMember("user") as GuildMember;
- const days: number = interaction.options.get("delete")?.value as number | null ?? 0;
+ const days: number = (interaction.options.get("delete")?.value as number | null) ?? 0;
member.ban({
deleteMessageSeconds: days * 24 * 60 * 60,
reason: reason ?? "*No reason provided*"
@@ -137,7 +154,9 @@
serverMemberCount: interaction.guild.memberCount
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -181,12 +200,12 @@
let apply = interaction.options.getUser("user") as User | GuildMember;
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
- let applyPos = 0
+ let applyPos = 0;
try {
- apply = await interaction.guild.members.fetch(apply.id) as GuildMember
+ apply = (await interaction.guild.members.fetch(apply.id)) as GuildMember;
applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
} catch {
- apply = apply as User
+ apply = apply as User;
}
// Do not allow banning the owner
if (member.id === interaction.guild.ownerId) return "You cannot softban the owner of the server";
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 40f4504..7397414 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -48,7 +48,13 @@
try {
await interaction.guild.members.unban(resolved.user as User, "Unban");
const member = resolved.user as User;
- await client.database.history.create("unban", interaction.guild.id, member, interaction.user, "No reason provided");
+ await client.database.history.create(
+ "unban",
+ interaction.guild.id,
+ member,
+ interaction.user,
+ "No reason provided"
+ );
const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 8562c4c..f248a3b 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -29,8 +29,7 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
reason: `\n> ${reason ? reason : "*No reason provided*"}`
- }) +
- `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")
.addCustomBoolean(
@@ -115,7 +114,9 @@
unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -139,8 +140,7 @@
if (!interaction.guild) return;
const member = interaction.member as GuildMember;
// Check if the user has moderate_members permission
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
if (partial) return true;
const me = interaction.guild.members.me!;
const apply = interaction.options.getMember("user") as GuildMember;
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ef62816..41f34b9 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaults.js';
+import { LoadingEmbed } from "./../../utils/defaults.js";
import Discord, {
CommandInteraction,
GuildMember,
@@ -23,20 +23,19 @@
.addUserOption((option) => option.setName("member").setDescription("The member to view as").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
+ const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
-
- let channels: Record<string, GuildBasedChannel[]> = {"": []};
+ let channels: Record<string, GuildBasedChannel[]> = { "": [] };
const channelCollection = await interaction.guild!.channels.fetch();
- channelCollection.forEach(channel => {
+ channelCollection.forEach((channel) => {
if (!channel) return; // if no channel
if (channel.type === Discord.ChannelType.GuildCategory) {
- if(!channels[channel!.id]) channels[channel!.id] = [];
+ if (!channels[channel!.id]) channels[channel!.id] = [];
} else if (channel.parent) {
if (!channels[channel.parent.id]) channels[channel.parent.id] = [channel];
- else (channels[channel.parent.id as string])!.push(channel);
+ else channels[channel.parent.id as string]!.push(channel);
} else {
channels[""]!.push(channel);
}
@@ -47,7 +46,11 @@
for (const category in channels) {
channels[category] = channels[category]!.sort((a: GuildBasedChannel, b: GuildBasedChannel) => {
- const disallowedTypes = [Discord.ChannelType.PublicThread, Discord.ChannelType.PrivateThread, Discord.ChannelType.AnnouncementThread];
+ const disallowedTypes = [
+ Discord.ChannelType.PublicThread,
+ Discord.ChannelType.PrivateThread,
+ Discord.ChannelType.AnnouncementThread
+ ];
if (disallowedTypes.includes(a.type) || disallowedTypes.includes(b.type)) return 0;
a = a as NonThreadGuildBasedChannel;
b = b as NonThreadGuildBasedChannel;
@@ -64,7 +67,11 @@
}
for (const category in channels) {
channels[category] = channels[category]!.filter((c) => {
- return !(c.type === Discord.ChannelType.PublicThread || c.type === Discord.ChannelType.PrivateThread || c.type === Discord.ChannelType.AnnouncementThread)
+ return !(
+ c.type === Discord.ChannelType.PublicThread ||
+ c.type === Discord.ChannelType.PrivateThread ||
+ c.type === Discord.ChannelType.AnnouncementThread
+ );
});
}
channels = Object.fromEntries(Object.entries(channels).filter(([_, v]) => v.length > 0));
@@ -81,12 +88,12 @@
if (last25.length > 0) categoryNames25.push(last25);
const channelTypeEmoji: Record<number, string> = {
- 0: "GUILD_TEXT", // Text channel
- 2: "GUILD_VOICE", // Voice channel
- 5: "GUILD_NEWS", // Announcement channel
- 13: "GUILD_STAGE_VOICE", // Stage channel
- 15: "FORUM", // Forum channel
- 99: "RULES" // Rules channel
+ 0: "GUILD_TEXT", // Text channel
+ 2: "GUILD_VOICE", // Voice channel
+ 5: "GUILD_NEWS", // Announcement channel
+ 13: "GUILD_STAGE_VOICE", // Stage channel
+ 15: "FORUM", // Forum channel
+ 99: "RULES" // Rules channel
};
const NSFWAvailable: number[] = [0, 2, 5, 13];
const rulesChannel = interaction.guild!.rulesChannel?.id;
@@ -94,12 +101,12 @@
async function nameFromChannel(channel: GuildBasedChannel): Promise<string> {
let channelType: Discord.ChannelType | 99 = channel.type;
if (channelType === Discord.ChannelType.GuildCategory) return "";
- if (channel.id === rulesChannel) channelType = 99
+ if (channel.id === rulesChannel) channelType = 99;
let threads: Discord.ThreadChannel[] = [];
if ("threads" in channel) {
threads = channel.threads.cache.toJSON().map((t) => t as Discord.ThreadChannel);
}
- const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType)
+ const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType);
const emojiName = channelTypeEmoji[channelType.valueOf()] + (nsfw ? "_NSFW" : "");
const emoji = getEmojiByName("ICONS.CHANNEL." + (threads.length ? "THREAD_CHANNEL" : emojiName));
let current = `${emoji} ${channel.name}`;
@@ -118,46 +125,59 @@
description += `${await nameFromChannel(channel)}\n`;
}
- const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] = categoryNames25.map(
- (categories, set) => { return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(new StringSelectMenuBuilder()
- .setCustomId("category")
- .setMinValues(1)
- .setMaxValues(1)
- .setOptions(categories.map((c, i) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(c)
- .setValue((set * 25 + i).toString())
- .setEmoji(getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji) // Again, this is valid but TS doesn't think so
- .setDefault((set * 25 + i) === page)
- }))
- )}
+ const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] =
+ categoryNames25.map((categories, set) => {
+ return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("category")
+ .setMinValues(1)
+ .setMaxValues(1)
+ .setOptions(
+ categories.map((c, i) => {
+ return new StringSelectMenuOptionBuilder()
+ .setLabel(c)
+ .setValue((set * 25 + i).toString())
+ .setEmoji(
+ getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji
+ ) // Again, this is valid but TS doesn't think so
+ .setDefault(set * 25 + i === page);
+ })
+ )
+ );
+ });
+
+ const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu;
+ components.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
+ new ButtonBuilder()
+ .setCustomId("right")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === categoryIDs.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ )
);
- const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu
- components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === 0)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
- new ButtonBuilder()
- .setCustomId("right")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === categoryIDs.length - 1)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- ));
-
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
- ], components: components
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
+ ],
+ components: components
});
let i;
try {
- i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 30000});
+ i = await m.awaitMessageComponent({
+ filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id,
+ time: 30000
+ });
} catch (e) {
closed = true;
continue;
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index ea4f084..5d1bd94 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -32,15 +32,15 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")!),
reason: reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*"
- }) +
- `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(
"appeal",
"Create appeal ticket",
!(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ async () =>
+ await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created",
null,
"CONTROL.TICKET",
@@ -67,13 +67,18 @@
notify = confirmation.components["notify"]!.active;
createAppealTicket = confirmation.components["appeal"]!.active;
}
- } while (!timedOut && !success)
+ } while (!timedOut && !success);
if (timedOut || !success) return;
let dmSent = false;
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
+ if (reason) {
+ reason = reason
+ .split("\n")
+ .map((line) => "> " + line)
+ .join("\n");
+ }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -87,7 +92,9 @@
(reason ? ` for:\n${reason}` : ".\n*No reason was provided*") +
"\n\n" +
(createAppealTicket
- ? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
+ ? `You can appeal this in the ticket created in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Danger")
@@ -95,14 +102,20 @@
components: []
};
if (config.moderation.warn.text && config.moderation.warn.link) {
- messageData.embeds[0]!.setFooter(LinkWarningFooter)
- messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
- .addComponents(new ButtonBuilder()
+ messageData.embeds[0]!.setFooter(LinkWarningFooter);
+ messageData.components.push(
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
+ new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
- )
- )
+ .setURL(
+ config.moderation.warn.link.replaceAll(
+ "{id}",
+ (interaction.options.getMember("user") as GuildMember).id
+ )
+ )
+ )
+ );
}
await (interaction.options.getMember("user") as GuildMember).send(messageData);
dmSent = true;
@@ -128,7 +141,9 @@
reason: reason ? reason : "*No reason provided*"
},
separate: {
- end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
+ end:
+ getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) +
+ ` The user was ${notify ? "" : "not "}notified`
},
hidden: {
guild: interaction.guild.id
@@ -152,7 +167,9 @@
.setDescription(
"The user was warned" +
(createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ ? ` and an appeal ticket was opened in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Success")
@@ -173,7 +190,10 @@
],
components: [
new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
- new Discord.ButtonBuilder().setCustomId("log").setLabel("Ignore and log").setStyle(ButtonStyle.Secondary),
+ new Discord.ButtonBuilder()
+ .setCustomId("log")
+ .setLabel("Ignore and log")
+ .setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder()
.setCustomId("here")
.setLabel("Warn here")
@@ -190,7 +210,8 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
time: 300000
});
} catch (e) {
@@ -227,7 +248,9 @@
.setDescription(
"The user was warned" +
(createAppealTicket
- ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
+ ? ` and an appeal ticket was opened in <#${
+ confirmation.components!["appeal"]!.response
+ }>`
: "")
)
.setStatus("Success")
@@ -282,9 +305,8 @@
const check = (interaction: CommandInteraction, partial: boolean = false) => {
if (!interaction.guild) return;
const member = interaction.member as GuildMember;
- if (!member.permissions.has("ModerateMembers"))
- return "You do not have the *Moderate Members* permission";
- if(partial) return true;
+ if (!member.permissions.has("ModerateMembers")) return "You do not have the *Moderate Members* permission";
+ if (partial) return true;
const apply = interaction.options.getMember("user") as GuildMember | null;
if (apply === null) return "That member is not in the server";
const memberPos = member.roles.cache.size ? member.roles.highest.position : 0;