Fix a bunch of linter errors
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index c2a76a9..7bdd813 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -1,4 +1,4 @@
const name = "mod";
const description = "Perform moderator actions";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index a55dcfa..4560c8b 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,8 +15,20 @@
builder
.setName("ban")
.setDescription("Bans a user from the server")
- .addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
- .addNumberOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to ban")
+ .setRequired(true)
+ )
+ .addNumberOption((option) =>
+ option
+ .setName("delete")
+ .setDescription("The days of messages to delete | Default: 0")
+ .setMinValue(0)
+ .setMaxValue(7)
+ .setRequired(false)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
@@ -23,13 +40,25 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n`
- + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
- + `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n` +
+ `${addPlurals(
+ interaction.options.getInteger("delete")
+ ? interaction.options.getInteger("delete")
+ : 0,
+ "day"
+ )} of messages will be deleted\n\n` +
+ `Are you sure you want to ban <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -37,7 +66,8 @@
if (confirmation.cancelled) return;
if (confirmation.success) break;
if (confirmation.newReason) reason = confirmation.newReason;
- if (confirmation.components) notify = confirmation.components.notify.active;
+ if (confirmation.components)
+ notify = confirmation.components.notify.active;
}
if (confirmation.success) {
let dmd = false;
@@ -45,31 +75,52 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Banned")
- .setDescription(`You have been banned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Banned")
+ .setDescription(
+ `You have been banned in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.ban.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- const member = (interaction.options.getMember("user") as GuildMember);
+ const member = interaction.options.getMember("user") as GuildMember;
member.ban({
days: Number(interaction.options.getNumber("delete") ?? 0),
reason: reason ?? "No reason provided"
});
- await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ await client.database.history.create(
+ "ban",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberBan",
@@ -82,10 +133,22 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
- reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ banned: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ bannedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ reason: entry(
+ reason,
+ reason ? `\n> ${reason}` : "*No reason provided.*"
+ ),
+ accountCreated: entry(
+ member.user.createdAt,
+ renderDelta(member.user.createdAt)
+ ),
serverMemberCount: interaction.guild.memberCount
},
hidden: {
@@ -94,56 +157,79 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Ban")
- .setDescription("Something went wrong and the user was not banned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Ban")
+ .setDescription(
+ "Something went wrong and the user was not banned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Ban")
- .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Ban")
+ .setDescription(
+ "The member was banned" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Ban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.GREEN")
+ .setTitle("Ban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow banning the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot ban the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot ban the owner of the server";
// Check if Nucleus can ban the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to ban
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Do not allow banning Nucleus
if (member.id === interaction.guild.me.id) throw "I cannot ban myself";
// Allow the owner to ban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow ban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 68b3ce7..86a4c4a 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,5 +1,11 @@
import { HistorySchema } from "../../utils/database";
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ TextInputComponent
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -11,51 +17,88 @@
builder
.setName("info")
.setDescription("Shows moderator information about a user")
- .addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to get information about")
+ .setRequired(true)
+ );
const types = {
- "warn": {emoji: "PUNISH.WARN.YELLOW", text: "Warned"},
- "mute": {emoji: "PUNISH.MUTE.YELLOW", text: "Muted"},
- "unmute": {emoji: "PUNISH.MUTE.GREEN", text: "Unmuted"},
- "join": {emoji: "MEMBER.JOIN", text: "Joined"},
- "leave": {emoji: "MEMBER.LEAVE", text: "Left"},
- "kick": {emoji: "MEMBER.KICK", text: "Kicked"},
- "softban": {emoji: "PUNISH.SOFTBAN", text: "Softbanned"},
- "ban": {emoji: "MEMBER.BAN", text: "Banned"},
- "unban": {emoji: "MEMBER.UNBAN", text: "Unbanned"},
- "purge": {emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared"},
- "nickname": {emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed"}
+ warn: { emoji: "PUNISH.WARN.YELLOW", text: "Warned" },
+ mute: { emoji: "PUNISH.MUTE.YELLOW", text: "Muted" },
+ unmute: { emoji: "PUNISH.MUTE.GREEN", text: "Unmuted" },
+ join: { emoji: "MEMBER.JOIN", text: "Joined" },
+ leave: { emoji: "MEMBER.LEAVE", text: "Left" },
+ kick: { emoji: "MEMBER.KICK", text: "Kicked" },
+ softban: { emoji: "PUNISH.SOFTBAN", text: "Softbanned" },
+ ban: { emoji: "MEMBER.BAN", text: "Banned" },
+ unban: { emoji: "MEMBER.UNBAN", text: "Unbanned" },
+ purge: { emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared" },
+ nickname: { emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed" }
};
function historyToString(history: HistorySchema) {
let s = `${getEmojiByName(types[history.type].emoji)} ${
- history.amount ? (history.amount + " ") : ""
- }${
- types[history.type].text
- } on <t:${Math.round(history.occurredAt.getTime() / 1000)}:F>`;
- if (history.moderator) { s += ` by <@${history.moderator}>`; }
- if (history.reason) { s += `\n**Reason:**\n> ${history.reason}`; }
- if (history.before) { s += `\n**Before:**\n> ${history.before}`; }
- if (history.after) { s += `\n**After:**\n> ${history.after}`; }
+ history.amount ? history.amount + " " : ""
+ }${types[history.type].text} on <t:${Math.round(
+ history.occurredAt.getTime() / 1000
+ )}:F>`;
+ if (history.moderator) {
+ s += ` by <@${history.moderator}>`;
+ }
+ if (history.reason) {
+ s += `\n**Reason:**\n> ${history.reason}`;
+ }
+ if (history.before) {
+ s += `\n**Before:**\n> ${history.before}`;
+ }
+ if (history.after) {
+ s += `\n**After:**\n> ${history.after}`;
+ }
return s + "\n";
}
-
class TimelineSection {
name: string;
- content: {data: HistorySchema, rendered: string}[] = [];
+ content: { data: HistorySchema; rendered: string }[] = [];
- addContent = (content: {data: HistorySchema, rendered: string}) => { this.content.push(content); return this; };
- contentLength = () => { return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0); };
+ addContent = (content: { data: HistorySchema; rendered: string }) => {
+ this.content.push(content);
+ return this;
+ };
+ contentLength = () => {
+ return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0);
+ };
generateName = () => {
- const first = Math.round(this.content[0].data.occurredAt.getTime() / 1000);
- const last = Math.round(this.content[this.content.length - 1].data.occurredAt.getTime() / 1000);
- if (first === last) { return this.name = `<t:${first}:F>`; }
- return this.name = `<t:${first}:F> - <t:${last}:F>`;
+ const first = Math.round(
+ this.content[0].data.occurredAt.getTime() / 1000
+ );
+ const last = Math.round(
+ this.content[this.content.length - 1].data.occurredAt.getTime() /
+ 1000
+ );
+ if (first === last) {
+ return (this.name = `<t:${first}:F>`);
+ }
+ return (this.name = `<t:${first}:F> - <t:${last}:F>`);
};
}
-const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+const monthNames = [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+];
async function showHistory(member, interaction: CommandInteraction) {
let currentYear = new Date().getFullYear();
@@ -66,41 +109,72 @@
let openFilterPane = false;
while (true) {
if (refresh) {
- history = await client.database.history.read(member.guild.id, member.id, currentYear);
- history = history.sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime()).reverse();
+ history = await client.database.history.read(
+ member.guild.id,
+ member.id,
+ currentYear
+ );
+ history = history
+ .sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime())
+ .reverse();
if (openFilterPane) {
let tempFilteredTypes = filteredTypes;
- if (filteredTypes.length === 0) { tempFilteredTypes = Object.keys(types); }
- history = history.filter(h => tempFilteredTypes.includes(h.type));
+ if (filteredTypes.length === 0) {
+ tempFilteredTypes = Object.keys(types);
+ }
+ history = history.filter((h) =>
+ tempFilteredTypes.includes(h.type)
+ );
}
refresh = false;
}
const groups: TimelineSection[] = [];
if (history.length > 0) {
current = new TimelineSection();
- history.forEach(event => {
- if (current.contentLength() + historyToString(event).length > 2000 || current.content.length === 5) {
+ history.forEach((event) => {
+ if (
+ current.contentLength() + historyToString(event).length >
+ 2000 ||
+ current.content.length === 5
+ ) {
groups.push(current);
current.generateName();
current = new TimelineSection();
}
- current.addContent({data: event, rendered: historyToString(event)});
+ current.addContent({
+ data: event,
+ rendered: historyToString(event)
+ });
});
current.generateName();
groups.push(current);
- if (pageIndex === null) { pageIndex = groups.length - 1; }
+ if (pageIndex === null) {
+ pageIndex = groups.length - 1;
+ }
}
const components = (
- openFilterPane ? [
- new MessageActionRow().addComponents([new Discord.MessageSelectMenu().setOptions(
- Object.entries(types).map(([key, value]) => ({
- label: value.text,
- value: key,
- default: filteredTypes.includes(key),
- emoji: client.emojis.resolve(getEmojiByName(value.emoji, "id"))
- }))
- ).setMinValues(1).setMaxValues(Object.keys(types).length).setCustomId("filter").setPlaceholder("Select at least one event")])
- ] : []).concat([
+ openFilterPane
+ ? [
+ new MessageActionRow().addComponents([
+ new Discord.MessageSelectMenu()
+ .setOptions(
+ Object.entries(types).map(([key, value]) => ({
+ label: value.text,
+ value: key,
+ default: filteredTypes.includes(key),
+ emoji: client.emojis.resolve(
+ getEmojiByName(value.emoji, "id")
+ )
+ }))
+ )
+ .setMinValues(1)
+ .setMaxValues(Object.keys(types).length)
+ .setCustomId("filter")
+ .setPlaceholder("Select at least one event")
+ ])
+ ]
+ : []
+ ).concat([
new MessageActionRow().addComponents([
new MessageButton()
.setCustomId("prevYear")
@@ -119,14 +193,18 @@
.setCustomId("nextPage")
.setLabel("Next page")
.setStyle("PRIMARY")
- .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ .setDisabled(
+ pageIndex >= groups.length - 1 &&
+ currentYear === new Date().getFullYear()
+ ),
new MessageButton()
.setCustomId("nextYear")
.setLabel((currentYear + 1).toString())
.setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
.setStyle("SECONDARY")
.setDisabled(currentYear === new Date().getFullYear())
- ]), new MessageActionRow().addComponents([
+ ]),
+ new MessageActionRow().addComponents([
new MessageButton()
.setLabel("Mod notes")
.setCustomId("modNotes")
@@ -139,40 +217,82 @@
.setEmoji(getEmojiByName("ICONS.FILTER", "id"))
])
]);
- const end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
- Math.max(groups.length, 1),
- groups.length === 0 ? 1 : pageIndex
- ) + (currentYear === new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
- ) + " " + currentYear.toString();
+ const end =
+ "\n\nJanuary " +
+ currentYear.toString() +
+ pageIndicator(
+ Math.max(groups.length, 1),
+ groups.length === 0 ? 1 : pageIndex
+ ) +
+ (currentYear === new Date().getFullYear()
+ ? monthNames[new Date().getMonth()]
+ : "December") +
+ " " +
+ currentYear.toString();
if (groups.length > 0) {
const toRender = groups[Math.min(pageIndex, groups.length - 1)];
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(`**${toRender.name}**\n\n` + toRender.content.map(c => c.rendered).join("\n") + end)
- .setStatus("Success")
- .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
- ], components: components});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(
+ `**${toRender.name}**\n\n` +
+ toRender.content
+ .map((c) => c.rendered)
+ .join("\n") +
+ end
+ )
+ .setStatus("Success")
+ .setFooter({
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : ""
+ })
+ ],
+ components: components
+ });
} else {
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(`**${currentYear}**\n\n*No events*` + "\n\n" + end)
- .setStatus("Success")
- .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
- ], components: components});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(
+ `**${currentYear}**\n\n*No events*` + "\n\n" + end
+ )
+ .setStatus("Success")
+ .setFooter({
+ text:
+ openFilterPane && filteredTypes.length
+ ? "Filters are currently enabled"
+ : ""
+ })
+ ],
+ components: components
+ });
}
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Moderation history for " + member.user.username)
- .setDescription(m.embeds[0].description)
- .setStatus("Danger")
- .setFooter({text: "Message timed out"})
- ]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle(
+ "Moderation history for " + member.user.username
+ )
+ .setDescription(m.embeds[0].description)
+ .setStatus("Danger")
+ .setFooter({ text: "Message timed out" })
+ ]
+ });
return 0;
}
i.deferUpdate();
@@ -181,103 +301,170 @@
pageIndex = null;
refresh = true;
}
- if (i.customId === "prevYear") { currentYear--; pageIndex = null; refresh = true; }
- if (i.customId === "nextYear") { currentYear++; pageIndex = null; refresh = true; }
+ if (i.customId === "prevYear") {
+ currentYear--;
+ pageIndex = null;
+ refresh = true;
+ }
+ if (i.customId === "nextYear") {
+ currentYear++;
+ pageIndex = null;
+ refresh = true;
+ }
if (i.customId === "prevPage") {
pageIndex--;
- if (pageIndex < 0) { pageIndex = null; currentYear--; refresh = true; }
+ if (pageIndex < 0) {
+ pageIndex = null;
+ currentYear--;
+ refresh = true;
+ }
}
if (i.customId === "nextPage") {
pageIndex++;
- if (pageIndex >= groups.length) { pageIndex = 0; currentYear++; refresh = true; }
+ if (pageIndex >= groups.length) {
+ pageIndex = 0;
+ currentYear++;
+ refresh = true;
+ }
}
- if (i.customId === "today") { currentYear = new Date().getFullYear(); pageIndex = null; refresh = true; }
- if (i.customId === "modNotes") { return 1; }
- if (i.customId === "openFilter") { openFilterPane = !openFilterPane; refresh = true; }
+ if (i.customId === "today") {
+ currentYear = new Date().getFullYear();
+ pageIndex = null;
+ refresh = true;
+ }
+ if (i.customId === "modNotes") {
+ return 1;
+ }
+ if (i.customId === "openFilter") {
+ openFilterPane = !openFilterPane;
+ refresh = true;
+ }
}
}
-
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
let m;
- const member = (interaction.options.getMember("user")) as Discord.GuildMember;
- await interaction.reply({embeds: [new EmojiEmbed()
- .setEmoji("NUCLEUS.LOADING")
- .setTitle("Downloading Data")
- .setStatus("Danger")
- ], ephemeral: true, fetchReply: true});
+ const member = interaction.options.getMember("user") as Discord.GuildMember;
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("NUCLEUS.LOADING")
+ .setTitle("Downloading Data")
+ .setStatus("Danger")
+ ],
+ ephemeral: true,
+ fetchReply: true
+ });
let note;
let firstLoad = true;
while (true) {
note = await client.database.notes.read(member.guild.id, member.id);
- if (firstLoad && !note) { await showHistory(member, interaction); }
+ if (firstLoad && !note) {
+ await showHistory(member, interaction);
+ }
firstLoad = false;
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Mod notes for " + member.user.username)
- .setDescription(note ? note : "*No note set*")
- .setStatus("Success")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel(`${note ? "Modify" : "Create"} note`)
- .setStyle("PRIMARY")
- .setCustomId("modify")
- .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
- new MessageButton()
- .setLabel("View moderation history")
- .setStyle("PRIMARY")
- .setCustomId("history")
- .setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
- ])]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Mod notes for " + member.user.username)
+ .setDescription(note ? note : "*No note set*")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(`${note ? "Modify" : "Create"} note`)
+ .setStyle("PRIMARY")
+ .setCustomId("modify")
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new MessageButton()
+ .setLabel("View moderation history")
+ .setStyle("PRIMARY")
+ .setCustomId("history")
+ .setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return; }
+ } catch (e) {
+ return;
+ }
if (i.customId === "modify") {
- await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Editing moderator note").addComponents(
- new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
- .setCustomId("note")
- .setLabel("Note")
- .setMaxLength(4000)
- .setRequired(false)
- .setStyle("PARAGRAPH")
- .setValue(note ? note : "")
- )
- ));
+ await i.showModal(
+ new Discord.Modal()
+ .setCustomId("modal")
+ .setTitle("Editing moderator note")
+ .addComponents(
+ new MessageActionRow<TextInputComponent>().addComponents(
+ new TextInputComponent()
+ .setCustomId("note")
+ .setLabel("Note")
+ .setMaxLength(4000)
+ .setRequired(false)
+ .setStyle("PARAGRAPH")
+ .setValue(note ? note : "")
+ )
+ )
+ );
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setTitle("Mod notes for " + member.user.username)
- .setDescription("Modal opened. If you can't see it, click back and try again.")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Back")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("back")
- ])]
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Mod notes for " + member.user.username)
+ .setDescription(
+ "Modal opened. If you can't see it, click back and try again."
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])
+ ]
});
let out;
try {
- out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
- } catch (e) { continue; }
+ out = await modalInteractionCollector(
+ m,
+ (m) => m.channel.id === interaction.channel.id,
+ (m) => m.customId === "modify"
+ );
+ } catch (e) {
+ continue;
+ }
if (out.fields) {
const toAdd = out.fields.getTextInputValue("note") || null;
- await client.database.notes.create(member.guild.id, member.id, toAdd);
- } else { continue; }
+ await client.database.notes.create(
+ member.guild.id,
+ member.id,
+ toAdd
+ );
+ } else {
+ continue;
+ }
} else if (i.customId === "history") {
i.deferUpdate();
- if (!await showHistory(member, interaction) ) return;
+ if (!(await showHistory(member, interaction))) return;
}
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ const member = interaction.member as GuildMember;
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 23785c3..59c2f81 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import humanizeDuration from "humanize-duration";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -10,9 +15,16 @@
builder
.setName("kick")
.setDescription("Kicks a user from the server")
- .addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to kick")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -22,12 +34,19 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kick")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to kick <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -45,28 +64,51 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.RED")
- .setTitle("Kicked")
- .setDescription(`You have been kicked in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.RED")
+ .setTitle("Kicked")
+ .setDescription(
+ `You have been kicked in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.kick.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.kick.text)
- .setURL(config.moderation.kick.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.kick.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.kick.text)
+ .setURL(config.moderation.kick.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- (interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.");
- const member = (interaction.options.getMember("user") as GuildMember);
- await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ (interaction.options.getMember("user") as GuildMember).kick(
+ reason ?? "No reason provided."
+ );
+ const member = interaction.options.getMember("user") as GuildMember;
+ await client.database.history.create(
+ "kick",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberKick",
@@ -79,12 +121,35 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- kickedBy: entry(interaction.user.id, renderUser(interaction.user)),
- reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
- timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedTimestamp, { round: true })),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ joined: entry(
+ member.joinedAt,
+ renderDelta(member.joinedAt)
+ ),
+ kicked: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ kickedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ reason: entry(
+ reason,
+ reason ? `\n> ${reason}` : "*No reason provided.*"
+ ),
+ timeInServer: entry(
+ new Date().getTime() - member.joinedTimestamp,
+ humanizeDuration(
+ new Date().getTime() - member.joinedTimestamp,
+ {
+ round: true
+ }
+ )
+ ),
+ accountCreated: entry(
+ member.user.createdAt,
+ renderDelta(member.user.createdAt)
+ ),
serverMemberCount: member.guild.memberCount
},
hidden: {
@@ -93,56 +158,79 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.RED")
- .setTitle("Kick")
- .setDescription("Something went wrong and the user was not kicked")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.RED")
+ .setTitle("Kick")
+ .setDescription(
+ "Something went wrong and the user was not kicked"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Kick")
- .setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Kick")
+ .setDescription(
+ "The member was kicked" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.KICK.GREEN")
- .setTitle("Kick")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.KICK.GREEN")
+ .setTitle("Kick")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow kicking the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot kick the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot kick the owner of the server";
// Check if Nucleus can kick the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to kick
- if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the *Kick Members* permission";
+ if (!me.permissions.has("KICK_MEMBERS"))
+ throw "I do not have the *Kick Members* permission";
// Do not allow kicking Nucleus
if (member.id === interaction.guild.me.id) throw "I cannot kick myself";
// Allow the owner to kick anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has kick_members permission
- if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the *Kick Members* permission";
+ if (!member.permissions.has("KICK_MEMBERS"))
+ throw "You do not have the *Kick Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow kick
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 1e9a812..5be6f43 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,5 +1,11 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Message,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -7,20 +13,69 @@
import keyValueList from "../../utils/generateKeyValueList.js";
import humanizeDuration from "humanize-duration";
import client from "../../utils/client.js";
-import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
+import {
+ areTicketsEnabled,
+ create
+} from "../../actions/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("mute")
- .setDescription("Mutes a member, stopping them from talking in the server")
- .addUserOption(option => option.setName("user").setDescription("The user to mute").setRequired(true))
- .addIntegerOption(option => option.setName("days").setDescription("The number of days to mute the user for | Default: 0").setMinValue(0).setMaxValue(27).setRequired(false))
- .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false))
- .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
- .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false));
+ .setDescription(
+ "Mutes a member, stopping them from talking in the server"
+ )
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to mute")
+ .setRequired(true)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("days")
+ .setDescription(
+ "The number of days to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(27)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("hours")
+ .setDescription(
+ "The number of hours to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(23)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("minutes")
+ .setDescription(
+ "The number of minutes to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(59)
+ .setRequired(false)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("seconds")
+ .setDescription(
+ "The number of seconds to mute the user for | Default: 0"
+ )
+ .setMinValue(0)
+ .setMaxValue(59)
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const { log, NucleusColors, renderUser, entry, renderDelta } =
+ client.logger;
const user = interaction.options.getMember("user") as GuildMember;
const time = {
days: interaction.options.getInteger("days") || 0,
@@ -29,85 +84,136 @@
seconds: interaction.options.getInteger("seconds") || 0
};
const config = await client.database.guilds.read(interaction.guild.id);
- let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "");
- if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`;
+ let serverSettingsDescription = config.moderation.mute.timeout
+ ? "given a timeout"
+ : "";
+ if (config.moderation.mute.role)
+ serverSettingsDescription +=
+ (serverSettingsDescription ? " and " : "") +
+ `given the <@&${config.moderation.mute.role}> role`;
- let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds;
+ let muteTime =
+ time.days * 24 * 60 * 60 +
+ time.hours * 60 * 60 +
+ time.minutes * 60 +
+ time.seconds;
if (muteTime === 0) {
- const m = await interaction.reply({embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Mute")
- .setDescription("How long should the user be muted")
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("1m")
- .setLabel("1 Minute")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("10m")
- .setLabel("10 Minutes")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("30m")
- .setLabel("30 Minutes")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1h")
- .setLabel("1 Hour")
- .setStyle("SECONDARY")
- ]),
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("6h")
- .setLabel("6 Hours")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("12h")
- .setLabel("12 Hours")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1d")
- .setLabel("1 Day")
- .setStyle("SECONDARY"),
- new Discord.MessageButton()
- .setCustomId("1w")
- .setLabel("1 Week")
- .setStyle("SECONDARY")
- ]),
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("cancel")
- .setLabel("Cancel")
- .setStyle("DANGER")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])
- ], ephemeral: true, fetchReply: true}) as Message;
+ const m = (await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Mute")
+ .setDescription("How long should the user be muted")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("1m")
+ .setLabel("1 Minute")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("10m")
+ .setLabel("10 Minutes")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("30m")
+ .setLabel("30 Minutes")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1h")
+ .setLabel("1 Hour")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("6h")
+ .setLabel("6 Hours")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("12h")
+ .setLabel("12 Hours")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1d")
+ .setLabel("1 Day")
+ .setStyle("SECONDARY"),
+ new Discord.MessageButton()
+ .setCustomId("1w")
+ .setLabel("1 Week")
+ .setStyle("SECONDARY")
+ ]),
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("cancel")
+ .setLabel("Cancel")
+ .setStyle("DANGER")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])
+ ],
+ ephemeral: true,
+ fetchReply: true
+ })) as Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
component.deferUpdate();
- if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Mute")
- .setDescription("Mute cancelled")
- .setStatus("Danger")
- ]});
+ if (component.customId === "cancel")
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Mute")
+ .setDescription("Mute cancelled")
+ .setStatus("Danger")
+ ]
+ });
switch (component.customId) {
- case "1m": { muteTime = 60; break; }
- case "10m": { muteTime = 60 * 10; break; }
- case "30m": { muteTime = 60 * 30; break; }
- case "1h": { muteTime = 60 * 60; break; }
- case "6h": { muteTime = 60 * 60 * 6; break; }
- case "12h": { muteTime = 60 * 60 * 12; break; }
- case "1d": { muteTime = 60 * 60 * 24; break; }
- case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
+ case "1m": {
+ muteTime = 60;
+ break;
+ }
+ case "10m": {
+ muteTime = 60 * 10;
+ break;
+ }
+ case "30m": {
+ muteTime = 60 * 30;
+ break;
+ }
+ case "1h": {
+ muteTime = 60 * 60;
+ break;
+ }
+ case "6h": {
+ muteTime = 60 * 60 * 6;
+ break;
+ }
+ case "12h": {
+ muteTime = 60 * 60 * 12;
+ break;
+ }
+ case "1d": {
+ muteTime = 60 * 60 * 24;
+ break;
+ }
+ case "1w": {
+ muteTime = 60 * 60 * 24 * 7;
+ break;
+ }
}
} else {
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ });
}
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -118,20 +224,47 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
- .setDescription(keyValueList({
- "user": renderUser(user.user),
- "time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + "The user will be " + serverSettingsDescription + "\n"
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to mute <@!${user.id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(user.user),
+ time: `${humanizeDuration(muteTime * 1000, {
+ round: true
+ })}`,
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ "The user will be " +
+ serverSettingsDescription +
+ "\n" +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to mute <@!${user.id}>?`
+ )
.setColor("Danger")
.addCustomBoolean(
- "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ "appeal",
+ "Create appeal ticket",
+ !(await areTicketsEnabled(interaction.guild.id)),
+ async () =>
+ await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason
+ ),
+ "An appeal ticket will be created when Confirm is clicked",
+ "CONTROL.TICKET",
+ createAppealTicket
+ )
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(true);
reason = reason ?? "";
@@ -150,69 +283,135 @@
try {
if (notify) {
dm = await user.send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Muted")
- .setDescription(`You have been muted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".\n\n" +
- `You will be unmuted at: <t:${Math.round((new Date).getTime() / 1000) + muteTime}:D> at <t:${Math.round((new Date).getTime() / 1000) + muteTime}:T> (<t:${Math.round((new Date).getTime() / 1000) + muteTime}:R>)`) +
- (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Muted")
+ .setDescription(
+ `You have been muted in ${interaction.guild.name}` +
+ (reason
+ ? ` for:\n> ${reason}`
+ : ".\n\n" +
+ `You will be unmuted at: <t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:D> at <t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:T> (<t:${
+ Math.round(
+ new Date().getTime() / 1000
+ ) + muteTime
+ }:R>)`) +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.mute.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.mute.text)
- .setURL(config.moderation.mute.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.mute.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.mute.text)
+ .setURL(config.moderation.mute.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
const member = user;
let errors = 0;
try {
if (config.moderation.mute.timeout) {
- await member.timeout(muteTime * 1000, reason || "No reason provided");
+ await member.timeout(
+ muteTime * 1000,
+ reason || "No reason provided"
+ );
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild.id,
- user: user.id,
- expires: new Date().getTime() + muteTime * 1000
- });
+ await client.database.eventScheduler.schedule(
+ "naturalUnmute",
+ new Date().getTime() + muteTime * 1000,
+ {
+ guild: interaction.guild.id,
+ user: user.id,
+ expires: new Date().getTime() + muteTime * 1000
+ }
+ );
}
}
- } catch { errors++; }
+ } catch {
+ errors++;
+ }
try {
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
- await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild.id,
- user: user.id,
- role: config.moderation.mute.role
- });
+ await client.database.eventScheduler.schedule(
+ "unmuteRole",
+ new Date().getTime() + muteTime * 1000,
+ {
+ guild: interaction.guild.id,
+ user: user.id,
+ role: config.moderation.mute.role
+ }
+ );
}
- } catch (e){ console.log(e); errors++; }
+ } catch (e) {
+ console.log(e);
+ errors++;
+ }
if (errors === 2) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Mute")
- .setDescription("Something went wrong and the user was not muted")
- .setStatus("Danger")
- ], components: []}); // TODO: make this clearer
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Mute")
+ .setDescription(
+ "Something went wrong and the user was not muted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ }); // TODO: make this clearer
if (dmd) await dm.delete();
return;
}
- await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Mute")
- .setDescription("The member was muted" + (failed ? ", but could not be notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ await client.database.history.create(
+ "mute",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ reason
+ );
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Mute")
+ .setDescription(
+ "The member was muted" +
+ (failed ? ", but could not be notified" : "") +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
const data = {
- meta:{
+ meta: {
type: "memberMute",
displayName: "Member Muted",
calculateType: "guildMemberPunish",
@@ -223,9 +422,18 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- mutedUntil: entry(new Date().getTime() + muteTime * 1000, renderDelta(new Date().getTime() + muteTime * 1000)),
- muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
- mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ mutedUntil: entry(
+ new Date().getTime() + muteTime * 1000,
+ renderDelta(new Date().getTime() + muteTime * 1000)
+ ),
+ muted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime() - 1000)
+ ),
+ mutedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
reason: entry(reason, reason ? reason : "*No reason provided*")
},
hidden: {
@@ -234,39 +442,49 @@
};
log(data);
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Mute")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Mute")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow muting the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot mute the owner of the server";
// Check if Nucleus can mute the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to mute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
+ if (!me.permissions.has("MODERATE_MEMBERS"))
+ throw "I do not have the *Moderate Members* permission";
// Do not allow muting Nucleus
if (member.id === me.id) throw "I cannot mute myself";
// Allow the owner to mute anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow mute
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 06fab47..c3d6b33 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -9,10 +9,22 @@
builder
.setName("nick")
.setDescription("Changes a users nickname")
- .addUserOption(option => option.setName("user").setDescription("The user to change").setRequired(true))
- .addStringOption(option => option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to change")
+ .setRequired(true)
+ )
+ .addStringOption((option) =>
+ option
+ .setName("name")
+ .setDescription("The name to set | Leave blank to clear")
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let notify = true;
@@ -21,14 +33,35 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ "new nickname": `${
+ interaction.options.getString("name")
+ ? interaction.options.getString("name")
+ : "*No nickname*"
+ }`
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to ${
+ interaction.options.getString("name")
+ ? "change"
+ : "clear"
+ } <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>'s nickname?`
+ )
.setColor("Danger")
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.send(interaction.options.getString("name") !== null);
if (confirmation.cancelled) return;
if (confirmation.success) break;
@@ -41,28 +74,53 @@
let dm;
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.RED")
- .setTitle("Nickname changed")
- .setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
- (interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : "") + "\n\n" +
- (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname changed")
+ .setDescription(
+ `Your nickname was ${
+ interaction.options.getString("name")
+ ? "changed"
+ : "cleared"
+ } in ${interaction.guild.name}.` +
+ (interaction.options.getString("name")
+ ? ` it is now: ${interaction.options.getString(
+ "name"
+ )}`
+ : "") +
+ "\n\n" +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
]
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
try {
- const member = (interaction.options.getMember("user") as GuildMember);
+ const member = interaction.options.getMember("user") as GuildMember;
const before = member.nickname;
const nickname = interaction.options.getString("name");
member.setNickname(nickname ?? null, "Nucleus Nickname command");
await client.database.history.create(
- "nickname", interaction.guild.id, member.user, interaction.user,
- null, before, nickname);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ "nickname",
+ interaction.guild.id,
+ member.user,
+ interaction.user,
+ null,
+ before,
+ nickname
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberUpdate",
@@ -76,8 +134,14 @@
memberId: entry(member.id, `\`${member.id}\``),
before: entry(before, before ? before : "*None*"),
after: entry(nickname, nickname ? nickname : "*None*"),
- updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- updatedBy: entry(interaction.user.id, renderUser(interaction.user))
+ updated: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ updatedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ )
},
hidden: {
guild: interaction.guild.id
@@ -85,56 +149,82 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.RED")
- .setTitle("Nickname")
- .setDescription("Something went wrong and the users nickname could not be changed.")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname")
+ .setDescription(
+ "Something went wrong and the users nickname could not be changed."
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Nickname")
- .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Nickname")
+ .setDescription(
+ "The members nickname was changed" +
+ (failed ? ", but was not notified" : "") +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setTitle("Nickname")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setTitle("Nickname")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow any changing of the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot change the owner's nickname";
// Check if Nucleus can change the nickname
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to change the nickname
- if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the *Manage Nicknames* permission";
+ if (!me.permissions.has("MANAGE_NICKNAMES"))
+ throw "I do not have the *Manage Nicknames* permission";
// Allow the owner to change anyone's nickname
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_nicknames permission
- if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the *Manage Nicknames* permission";
+ if (!member.permissions.has("MANAGE_NICKNAMES"))
+ throw "You do not have the *Manage Nicknames* permission";
// Allow changing your own nickname
if (member === apply) return true;
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow change
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index c554ee7..b78c423 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,9 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildChannel,
+ GuildMember,
+ TextChannel
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,19 +15,41 @@
builder
.setName("purge")
.setDescription("Bulk deletes messages in a channel")
- .addIntegerOption(option => option
- .setName("amount")
- .setDescription("The amount of messages to delete")
- .setRequired(false)
- .setMinValue(1)
- .setMaxValue(100))
- .addUserOption(option => option.setName("user").setDescription("The user to purge messages from").setRequired(false))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the purge").setRequired(false));
+ .addIntegerOption((option) =>
+ option
+ .setName("amount")
+ .setDescription("The amount of messages to delete")
+ .setRequired(false)
+ .setMinValue(1)
+ .setMaxValue(100)
+ )
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to purge messages from")
+ .setRequired(false)
+ )
+ .addStringOption((option) =>
+ option
+ .setName("reason")
+ .setDescription("The reason for the purge")
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const user = interaction.options.getMember("user") as GuildMember ?? null;
- const channel = (interaction.channel as GuildChannel);
- if (!(["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(channel.type.toString()))) {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const user = (interaction.options.getMember("user") as GuildMember) ?? null;
+ const channel = interaction.channel as GuildChannel;
+ if (
+ ![
+ "GUILD_TEXT",
+ "GUILD_NEWS",
+ "GUILD_NEWS_THREAD",
+ "GUILD_PUBLIC_THREAD",
+ "GUILD_PRIVATE_THREAD"
+ ].includes(channel.type.toString())
+ ) {
return await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -36,7 +63,7 @@
});
}
// TODO:[Modals] Replace this with a modal
- if ( !interaction.options.getInteger("amount") ) {
+ if (!interaction.options.getInteger("amount")) {
await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -51,12 +78,14 @@
});
let deleted = [] as Discord.Message[];
while (true) {
- const m = await interaction.editReply({
+ const m = (await interaction.editReply({
embeds: [
new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
- .setDescription("Select how many messages to delete. You can continue clicking until all messages are cleared.")
+ .setDescription(
+ "Select how many messages to delete. You can continue clicking until all messages are cleared."
+ )
.setStatus("Danger")
],
components: [
@@ -96,40 +125,64 @@
.setEmoji(getEmojiByName("CONTROL.TICK", "id"))
])
]
- }) as Discord.Message;
+ })) as Discord.Message;
let component;
try {
- component = m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch (e) { break; }
+ component = m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch (e) {
+ break;
+ }
component.deferUpdate();
if (component.customId === "done") break;
let amount;
- try { amount = parseInt(component.customId); } catch { break; }
+ try {
+ amount = parseInt(component.customId);
+ } catch {
+ break;
+ }
let messages;
- await (interaction.channel as TextChannel).messages.fetch({limit: amount}).then(async (ms) => {
- if (user) {
- ms = ms.filter(m => m.author.id === user.id);
- }
- messages = await (channel as TextChannel).bulkDelete(ms, true);
- });
+ await (interaction.channel as TextChannel).messages
+ .fetch({ limit: amount })
+ .then(async (ms) => {
+ if (user) {
+ ms = ms.filter((m) => m.author.id === user.id);
+ }
+ messages = await (channel as TextChannel).bulkDelete(
+ ms,
+ true
+ );
+ });
if (messages) {
- deleted = deleted.concat(messages.map(m => m));
+ deleted = deleted.concat(messages.map((m) => m));
}
}
- if (deleted.length === 0) return await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.RED")
- .setTitle("Purge")
- .setDescription("No messages were deleted")
- .setStatus("Danger")
- ],
- components: []
- });
+ if (deleted.length === 0)
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.RED")
+ .setTitle("Purge")
+ .setDescription("No messages were deleted")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (user) {
- await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, deleted.length);
+ await client.database.history.create(
+ "purge",
+ interaction.guild.id,
+ user,
+ interaction.options.getString("reason"),
+ null,
+ null,
+ deleted.length
+ );
}
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -140,9 +193,18 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ purgedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ channel: entry(
+ interaction.channel.id,
+ renderChannel(interaction.channel)
+ ),
messagesCleared: entry(deleted.length, deleted.length)
},
hidden: {
@@ -151,10 +213,16 @@
};
log(data);
let out = "";
- deleted.reverse().forEach(message => {
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+ deleted.reverse().forEach((message) => {
+ out += `${message.author.username}#${
+ message.author.discriminator
+ } (${message.author.id}) [${new Date(
+ message.createdTimestamp
+ ).toISOString()}]\n`;
const lines = message.content.split("\n");
- lines.forEach(line => {out += `> ${line}\n`;});
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
out += "\n\n";
});
const attachmentObject = {
@@ -162,47 +230,73 @@
name: `purge-${channel.id}-${Date.now()}.txt`,
description: "Purge log"
};
- const m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: [new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("download")
- .setLabel("Download transcript")
- .setStyle("SUCCESS")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ])]}) as Discord.Message;
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: [
+ new Discord.MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("download")
+ .setLabel("Download transcript")
+ .setStyle("SUCCESS")
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+ ])
+ ]
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Uploaded")
- .setStatus("Success")
- ], components: [], files: [attachmentObject]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Uploaded")
+ .setStatus("Success")
+ ],
+ components: [],
+ files: [attachmentObject]
+ });
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: []});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
return;
} else {
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
- .setDescription(keyValueList({
- "channel": `<#${channel.id}>`,
- "amount": interaction.options.getInteger("amount").toString(),
- "reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
- }))
+ .setDescription(
+ keyValueList({
+ channel: `<#${channel.id}>`,
+ amount: interaction.options.getInteger("amount").toString(),
+ reason: `\n> ${
+ interaction.options.getString("reason")
+ ? interaction.options.getString("reason")
+ : "*No reason provided*"
+ }`
+ })
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
@@ -210,25 +304,57 @@
let messages;
try {
if (!user) {
- const toDelete = await (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")});
- messages = await (channel as TextChannel).bulkDelete(toDelete, true);
+ const toDelete = await (
+ interaction.channel as TextChannel
+ ).messages.fetch({
+ limit: interaction.options.getInteger("amount")
+ });
+ messages = await (channel as TextChannel).bulkDelete(
+ toDelete,
+ true
+ );
} else {
- const toDelete = (await (await (interaction.channel as TextChannel).messages.fetch({limit: 100}))
- .filter(m => m.author.id === user.id)).first(interaction.options.getInteger("amount"));
- messages = await (channel as TextChannel).bulkDelete(toDelete, true);
+ const toDelete = (
+ await (
+ await (
+ interaction.channel as TextChannel
+ ).messages.fetch({
+ limit: 100
+ })
+ ).filter((m) => m.author.id === user.id)
+ ).first(interaction.options.getInteger("amount"));
+ messages = await (channel as TextChannel).bulkDelete(
+ toDelete,
+ true
+ );
}
- } catch(e) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.RED")
- .setTitle("Purge")
- .setDescription("Something went wrong and no messages were deleted")
- .setStatus("Danger")
- ], components: []});
+ } catch (e) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.RED")
+ .setTitle("Purge")
+ .setDescription(
+ "Something went wrong and no messages were deleted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
if (user) {
- await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, messages.size);
+ await client.database.history.create(
+ "purge",
+ interaction.guild.id,
+ user,
+ interaction.options.getString("reason"),
+ null,
+ null,
+ messages.size
+ );
}
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
meta: {
type: "channelPurge",
@@ -239,9 +365,18 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ purgedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ channel: entry(
+ interaction.channel.id,
+ renderChannel(interaction.channel)
+ ),
messagesCleared: entry(messages.size, messages.size)
},
hidden: {
@@ -250,10 +385,16 @@
};
log(data);
let out = "";
- messages.reverse().forEach(message => {
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+ messages.reverse().forEach((message) => {
+ out += `${message.author.username}#${
+ message.author.discriminator
+ } (${message.author.id}) [${new Date(
+ message.createdTimestamp
+ ).toISOString()}]\n`;
const lines = message.content.split("\n");
- lines.forEach(line => {out += `> ${line}\n`;});
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
out += "\n\n";
});
const attachmentObject = {
@@ -261,59 +402,85 @@
name: `purge-${channel.id}-${Date.now()}.txt`,
description: "Purge log"
};
- const m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: [new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("download")
- .setLabel("Download transcript")
- .setStyle("SUCCESS")
- .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
- ])]}) as Discord.Message;
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: [
+ new Discord.MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("download")
+ .setLabel("Download transcript")
+ .setStyle("SUCCESS")
+ .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+ ])
+ ]
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
- } catch { return; }
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Transcript uploaded above")
- .setStatus("Success")
- ], components: [], files: [attachmentObject]});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Transcript uploaded above")
+ .setStatus("Success")
+ ],
+ components: [],
+ files: [attachmentObject]
+ });
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("Messages cleared")
- .setStatus("Success")
- ], components: []});
+ interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("Messages cleared")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.PURGE.GREEN")
- .setTitle("Purge")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.GREEN")
+ .setTitle("Purge")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
// Check if nucleus has the manage_messages permission
- if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
+ if (!me.permissions.has("MANAGE_MESSAGES"))
+ throw "I do not have the *Manage Messages* permission";
// Allow the owner to purge
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_messages permission
- if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the *Manage Messages* permission";
+ if (!member.permissions.has("MANAGE_MESSAGES"))
+ throw "You do not have the *Manage Messages* permission";
// Allow purge
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 7e8b8a2..1a06db1 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -5,29 +5,51 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("slowmode")
.setDescription("Manages slowmode in a channel")
- .addStringOption(option => option.setName("time").setDescription("The delay between messages").setRequired(false).addChoices([
- ["Off", "0"],
- ["5 seconds", "5"], ["10 seconds", "10"], ["15 seconds", "15"], ["30 seconds", "30"],
- ["1 minute", "60"], ["2 minutes", "120"], ["5 minutes", "300"], ["10 minutes", "600"],
- ["15 minutes", "900"], ["30 minutes", "1800"],
- ["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
- ]));
+ .addStringOption((option) =>
+ option
+ .setName("time")
+ .setDescription("The delay between messages")
+ .setRequired(false)
+ .addChoices([
+ ["Off", "0"],
+ ["5 seconds", "5"],
+ ["10 seconds", "10"],
+ ["15 seconds", "15"],
+ ["30 seconds", "30"],
+ ["1 minute", "60"],
+ ["2 minutes", "120"],
+ ["5 minutes", "300"],
+ ["10 minutes", "600"],
+ ["15 minutes", "900"],
+ ["30 minutes", "1800"],
+ ["1 hour", "3600"],
+ ["2 hours", "7200"],
+ ["6 hours", "21600"]
+ ])
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
let time = parseInt(interaction.options.getString("time") ?? "0");
- if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10; }
+ if (
+ time === 0 &&
+ (interaction.channel as TextChannel).rateLimitPerUser === 0
+ ) {
+ time = 10;
+ }
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setTitle("Slowmode")
- .setDescription(keyValueList({
- "time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay"
- })
- + "Are you sure you want to set the slowmode in this channel?")
+ .setDescription(
+ keyValueList({
+ time: time
+ ? humanizeDuration(time * 1000, { round: true })
+ : "No delay"
+ }) + "Are you sure you want to set the slowmode in this channel?"
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
@@ -35,37 +57,53 @@
try {
(interaction.channel as TextChannel).setRateLimitPerUser(time);
} catch (e) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.OFF")
- .setTitle("Slowmode")
- .setDescription("Something went wrong while setting the slowmode")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
+ .setTitle("Slowmode")
+ .setDescription(
+ "Something went wrong while setting the slowmode"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.ON")
- .setTitle("Slowmode")
- .setDescription("The channel slowmode was set successfully")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.ON")
+ .setTitle("Slowmode")
+ .setDescription("The channel slowmode was set successfully")
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.ON")
- .setTitle("Slowmode")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.ON")
+ .setTitle("Slowmode")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
+ const member = interaction.member as GuildMember;
// Check if Nucleus can set the slowmode
- if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the *Manage Channels* permission";
+ if (!interaction.guild.me.permissions.has("MANAGE_CHANNELS"))
+ throw "I do not have the *Manage Channels* permission";
// Check if the user has manage_channel permission
- if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the *Manage Channels* permission";
+ if (!member.permissions.has("MANAGE_CHANNELS"))
+ throw "You do not have the *Manage Channels* permission";
// Allow slowmode
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index d0dc9bb..f3c475e 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,10 +15,24 @@
builder
.setName("softban")
.setDescription("Kicks a user and deletes their messages")
- .addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
- .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to softban")
+ .setRequired(true)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("delete")
+ .setDescription("The days of messages to delete | Default: 0")
+ .setMinValue(0)
+ .setMaxValue(7)
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,15 +42,35 @@
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n`
- + `${addPlural(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
- + `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n` +
+ `${addPlural(
+ interaction.options.getInteger("delete")
+ ? interaction.options.getInteger("delete")
+ : 0,
+ "day"
+ )} of messages will be deleted\n\n` +
+ `Are you sure you want to softban <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -47,24 +86,38 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softbanned")
- .setDescription(`You have been softbanned from ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softbanned")
+ .setDescription(
+ `You have been softbanned from ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
],
- components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ] : [])]
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.ban.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ]
+ : []
+ )
+ ]
});
dmd = true;
}
- } catch { dmd = false;}
- const member = (interaction.options.getMember("user") as GuildMember);
+ } catch {
+ dmd = false;
+ }
+ const member = interaction.options.getMember("user") as GuildMember;
try {
await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
@@ -72,55 +125,83 @@
});
await interaction.guild.members.unban(member, "Softban");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softban")
- .setDescription("Something went wrong and the user was not softbanned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softban")
+ .setDescription(
+ "Something went wrong and the user was not softbanned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await client.database.history.create("softban", interaction.guild.id, member.user, reason);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Softban")
- .setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ await client.database.history.create(
+ "softban",
+ interaction.guild.id,
+ member.user,
+ reason
+ );
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Softban")
+ .setDescription(
+ "The member was softbanned" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Softban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.GREEN")
+ .setTitle("Softban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow softbanning the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot softban the owner of the server";
// Check if Nucleus can ban the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Do not allow softbanning Nucleus
if (member.id === me.id) throw "I cannot softban myself";
// Allow the owner to softban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow softban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 88301eb..06fe647 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -9,39 +9,68 @@
builder
.setName("unban")
.setDescription("Unbans a user")
- .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true));
+ .addStringOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to unban (Username or ID)")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const bans = await interaction.guild.bans.fetch();
const user = interaction.options.getString("user");
- let resolved = bans.find(ban => ban.user.id === user);
- if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() === user.toLowerCase());
- if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() === user.toLowerCase());
+ let resolved = bans.find((ban) => ban.user.id === user);
+ if (!resolved)
+ resolved = bans.find(
+ (ban) => ban.user.username.toLowerCase() === user.toLowerCase()
+ );
+ if (!resolved)
+ resolved = bans.find(
+ (ban) => ban.user.tag.toLowerCase() === user.toLowerCase()
+ );
if (!resolved) {
- return interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Unban")
- .setDescription(`Could not find any user called \`${user}\``)
- .setEmoji("PUNISH.UNBAN.RED")
- .setStatus("Danger")
- ], ephemeral: true});
+ return interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Unban")
+ .setDescription(
+ `Could not find any user called \`${user}\``
+ )
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setStatus("Danger")
+ ],
+ ephemeral: true
+ });
}
// TODO:[Modals] Replace this with a modal
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.UNBAN.RED")
.setTitle("Unban")
- .setDescription(keyValueList({
- "user": `${resolved.user.username} [<@${resolved.user.id}>]`
- })
- + `Are you sure you want to unban <@${resolved.user.id}>?`)
+ .setDescription(
+ keyValueList({
+ user: `${resolved.user.username} [<@${resolved.user.id}>]`
+ }) + `Are you sure you want to unban <@${resolved.user.id}>?`
+ )
.setColor("Danger")
.send();
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await interaction.guild.members.unban(resolved.user as User, "Unban");
- const member = (resolved.user as User);
- await client.database.history.create("unban", interaction.guild.id, member, interaction.user);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ await interaction.guild.members.unban(
+ resolved.user as User,
+ "Unban"
+ );
+ const member = resolved.user as User;
+ await client.database.history.create(
+ "unban",
+ interaction.guild.id,
+ member,
+ interaction.user
+ );
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
const data = {
meta: {
type: "memberUnban",
@@ -54,9 +83,18 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member)),
- unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unbannedBy: entry(interaction.user.id, renderUser(interaction.user)),
- accountCreated: entry(member.createdAt, renderDelta(member.createdAt))
+ unbanned: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ unbannedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
+ accountCreated: entry(
+ member.createdAt,
+ renderDelta(member.createdAt)
+ )
},
hidden: {
guild: interaction.guild.id
@@ -64,40 +102,56 @@
};
log(data);
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.RED")
- .setTitle("Unban")
- .setDescription("Something went wrong and the user was not unbanned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setTitle("Unban")
+ .setDescription(
+ "Something went wrong and the user was not unbanned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.GREEN")
- .setTitle("Unban")
- .setDescription("The member was unbanned")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.GREEN")
+ .setTitle("Unban")
+ .setDescription("The member was unbanned")
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.UNBAN.GREEN")
- .setTitle("Unban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.GREEN")
+ .setTitle("Unban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
// Check if Nucleus can unban members
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Allow the owner to unban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Allow unban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index d4e0d75..f625461 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -9,24 +9,37 @@
builder
.setName("unmute")
.setDescription("Unmutes a user")
- .addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to unmute")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const { log, NucleusColors, renderUser, entry, renderDelta } =
+ client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
let notify = false;
let confirmation;
while (true) {
- confirmation = await new confirmationMessage(interaction)
+ confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Unmute")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": `\n> ${reason ? reason : "*No reason provided*"}`
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: `\n> ${reason ? reason : "*No reason provided*"}`
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to unmute <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addReasonButton(reason ?? "")
.send(reason !== null);
@@ -42,32 +55,53 @@
let dm;
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmuted")
- .setDescription(`You have been unmuted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : " with no reason provided."))
- .setStatus("Success")
+ dm = await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Unmuted")
+ .setDescription(
+ `You have been unmuted in ${interaction.guild.name}` +
+ (reason
+ ? ` for:\n> ${reason}`
+ : " with no reason provided.")
+ )
+ .setStatus("Success")
]
});
dmd = true;
}
- } catch { dmd = false; }
- const member = (interaction.options.getMember("user") as GuildMember);
+ } catch {
+ dmd = false;
+ }
+ const member = interaction.options.getMember("user") as GuildMember;
try {
member.timeout(0, reason || "No reason provided");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Unmute")
- .setDescription("Something went wrong and the user was not unmuted")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Unmute")
+ .setDescription(
+ "Something went wrong and the user was not unmuted"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
if (dmd) await dm.delete();
return;
}
- await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, reason);
+ await client.database.history.create(
+ "unmute",
+ interaction.guild.id,
+ (interaction.options.getMember("user") as GuildMember).user,
+ interaction.user,
+ reason
+ );
const data = {
meta: {
type: "memberUnmute",
@@ -80,53 +114,76 @@
list: {
memberId: entry(member.user.id, `\`${member.user.id}\``),
name: entry(member.user.id, renderUser(member.user)),
- unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
+ unmuted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ unmutedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ )
},
hidden: {
guild: interaction.guild.id
}
};
log(data);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Unmute")
- .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Unmute")
+ .setDescription(
+ "The member was unmuted" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmute")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Unmute")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow unmuting the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot unmute the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot unmute the owner of the server";
// Check if Nucleus can unmute the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to unmute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
+ if (!me.permissions.has("MODERATE_MEMBERS"))
+ throw "I do not have the *Moderate Members* permission";
// Allow the owner to unmute anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow unmute
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ca52787..f0b2047 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,11 @@
-import Discord, { CategoryChannel, CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+ CategoryChannel,
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ MessageSelectMenu
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -8,97 +15,189 @@
builder
.setName("viewas")
.setDescription("View the server as a specific member")
- .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("member")
+ .setDescription("The member to view as")
+ .setRequired(true)
+ );
const callback = async (interaction: CommandInteraction): Promise<void> => {
let channels = [];
let m;
- interaction.guild.channels.cache.forEach(channel => {
- if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel);
+ interaction.guild.channels.cache.forEach((channel) => {
+ if (!channel.parent && channel.type !== "GUILD_CATEGORY")
+ channels.push(channel);
});
channels = [channels];
- channels = channels.concat(interaction.guild.channels.cache
- .filter(c => c.type === "GUILD_CATEGORY")
- .map(c => (c as CategoryChannel).children.map(c => c))
+ channels = channels.concat(
+ interaction.guild.channels.cache
+ .filter((c) => c.type === "GUILD_CATEGORY")
+ .map((c) => (c as CategoryChannel).children.map((c) => c))
);
const autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"];
- channels = channels.map(c => c.sort((a, b) => {
- if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position;
- if (autoSortBelow.includes(a.type)) return 1;
- if (autoSortBelow.includes(b.type)) return -1;
- return a.position - b.position;
- }));
+ channels = channels.map((c) =>
+ c.sort((a, b) => {
+ if (
+ autoSortBelow.includes(a.type) &&
+ autoSortBelow.includes(b.type)
+ )
+ return a.position - b.position;
+ if (autoSortBelow.includes(a.type)) return 1;
+ if (autoSortBelow.includes(b.type)) return -1;
+ return a.position - b.position;
+ })
+ );
// Sort all arrays by the position of the first channels parent position
channels = channels.sort((a, b) => {
if (!a[0].parent) return -1;
if (!b[0].parent) return 1;
return a[0].parent.position - b[0].parent.position;
});
- const member = interaction.options.getMember("member") as Discord.GuildMember;
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- ], ephemeral: true, fetchReply: true});
+ const member = interaction.options.getMember(
+ "member"
+ ) as Discord.GuildMember;
+ m = await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ ],
+ ephemeral: true,
+ fetchReply: true
+ });
let page = 0;
while (true) {
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- .setDescription(
- `**${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}**` + "\n" +
- channels[page].map(c => {
- let channelType = c.type;
- if (interaction.guild.rulesChannelId === c.id) channelType = "RULES";
- else if ("nsfw" in c && c.nsfw) channelType += "_NSFW";
- return c.permissionsFor(member).has("VIEW_CHANNEL") ? (
- `${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` + (() => {
- if ("threads" in c && c.threads.cache.size > 0) {
- return c.threads.cache.map(t => ` ${
- getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") + " " +
- getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")} ${t.name}`).join("\n") + "\n";
- }return "";
- })()) : "";
- }).join("") + "\n" + pageIndicator(channels.length, page)
- )
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(channels.map((c, index) => ({
- label: c[0].parent ? c[0].parent.name : "Uncategorised",
- value: index.toString(),
- default: page === index
- }))).setCustomId("select").setMaxValues(1).setMinValues(1).setPlaceholder("Select a category")]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel(page === 0 ? "" : (channels[page - 1][0].parent ? channels[page - 1][0].parent.name : "Uncategorised"))
- .setDisabled(page === 0)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("previous"),
- new MessageButton()
- .setLabel(page === channels.length - 1 ? "" : (channels[page + 1][0].parent ? channels[page + 1][0].parent.name : "Uncategorised"))
- .setDisabled(page === channels.length - 1)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle("PRIMARY")
- .setCustomId("next")
- ])
- ]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ .setDescription(
+ `**${
+ channels[page][0].parent
+ ? channels[page][0].parent.name
+ : "Uncategorised"
+ }**` +
+ "\n" +
+ channels[page]
+ .map((c) => {
+ let channelType = c.type;
+ if (
+ interaction.guild.rulesChannelId ===
+ c.id
+ )
+ channelType = "RULES";
+ else if ("nsfw" in c && c.nsfw)
+ channelType += "_NSFW";
+ return c
+ .permissionsFor(member)
+ .has("VIEW_CHANNEL")
+ ? `${getEmojiByName(
+ "ICONS.CHANNEL." + channelType
+ )} ${c.name}\n` +
+ (() => {
+ if (
+ "threads" in c &&
+ c.threads.cache.size > 0
+ ) {
+ return (
+ c.threads.cache
+ .map(
+ (t) =>
+ ` ${
+ getEmojiByName(
+ "ICONS.CHANNEL.THREAD_PIPE"
+ ) +
+ " " +
+ getEmojiByName(
+ "ICONS.CHANNEL.THREAD_CHANNEL"
+ )
+ } ${
+ t.name
+ }`
+ )
+ .join("\n") + "\n"
+ );
+ }
+ return "";
+ })()
+ : "";
+ })
+ .join("") +
+ "\n" +
+ pageIndicator(channels.length, page)
+ )
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setOptions(
+ channels.map((c, index) => ({
+ label: c[0].parent
+ ? c[0].parent.name
+ : "Uncategorised",
+ value: index.toString(),
+ default: page === index
+ }))
+ )
+ .setCustomId("select")
+ .setMaxValues(1)
+ .setMinValues(1)
+ .setPlaceholder("Select a category")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(
+ page === 0
+ ? ""
+ : channels[page - 1][0].parent
+ ? channels[page - 1][0].parent.name
+ : "Uncategorised"
+ )
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("previous"),
+ new MessageButton()
+ .setLabel(
+ page === channels.length - 1
+ ? ""
+ : channels[page + 1][0].parent
+ ? channels[page + 1][0].parent.name
+ : "Uncategorised"
+ )
+ .setDisabled(page === channels.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("next")
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
- } catch (e) { return; }
+ } catch (e) {
+ return;
+ }
i.deferUpdate();
- if (i.customId === "next") { page++; }
- else if (i.customId === "previous") { page--; }
- else if (i.customId === "select") { page = parseInt(i.values[0]); }
+ if (i.customId === "next") {
+ page++;
+ } else if (i.customId === "previous") {
+ page--;
+ } else if (i.customId === "select") {
+ page = parseInt(i.values[0]);
+ }
}
};
-
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
+ const member = interaction.member as GuildMember;
+ if (!member.permissions.has("MANAGE_ROLES"))
+ throw "You do not have the *Manage Roles* permission";
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 34ad3c3..91c876e 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,18 +1,33 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
+import {
+ create,
+ areTicketsEnabled
+} from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("warn")
.setDescription("Warns a user")
- .addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to warn")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { log, NucleusColors, renderUser, entry } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,18 +38,44 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n\n`
- + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n\n` +
+ `Are you sure you want to warn <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addCustomBoolean(
- "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ "appeal",
+ "Create appeal ticket",
+ !(await areTicketsEnabled(interaction.guild.id)),
+ async () =>
+ await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason
+ ),
+ "An appeal ticket will be created when Confirm is clicked",
+ "CONTROL.TICKET",
+ createAppealTicket
+ )
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -50,31 +91,51 @@
let dmd = false;
try {
if (notify) {
- const config = await client.database.guilds.read(interaction.guild.id);
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warned")
- .setDescription(`You have been warned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
- (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
- .setFooter({
- text: config.moderation.warn.text ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site." : "",
- iconURL: "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
- })
+ const config = await client.database.guilds.read(
+ interaction.guild.id
+ );
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warned")
+ .setDescription(
+ `You have been warned in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".") +
+ "\n\n" +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
+ .setFooter({
+ text: config.moderation.warn.text
+ ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site."
+ : "",
+ iconURL:
+ "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
+ })
],
- components: config.moderation.warn.text ? [new MessageActionRow().addComponents([new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link)
- ])] : []
+ components: config.moderation.warn.text
+ ? [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.warn.text)
+ .setURL(config.moderation.warn.link)
+ ])
+ ]
+ : []
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
const data = {
- meta:{
+ meta: {
type: "memberWarn",
displayName: "Member warned",
calculateType: "guildMemberPunish",
@@ -83,8 +144,18 @@
timestamp: new Date().getTime()
},
list: {
- user: entry((interaction.options.getMember("user") as GuildMember).user.id, renderUser((interaction.options.getMember("user") as GuildMember).user)),
- warnedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ user: entry(
+ (interaction.options.getMember("user") as GuildMember).user
+ .id,
+ renderUser(
+ (interaction.options.getMember("user") as GuildMember)
+ .user
+ )
+ ),
+ warnedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
reason: reason ? `\n> ${reason}` : "No reason provided"
},
hidden: {
@@ -92,28 +163,47 @@
}
};
await client.database.history.create(
- "warn", interaction.guild.id,
+ "warn",
+ interaction.guild.id,
(interaction.options.getMember("user") as GuildMember).user,
- interaction.user, reason
+ interaction.user,
+ reason
);
log(data);
- const failed = (dmd === false && notify);
+ const failed = !dmd && notify;
if (!failed) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- const canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL");
- const m = await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("The user's DMs are not open\n\nWhat would you like to do?")
- .setStatus("Danger")
- ], components: [
+ const canSeeChannel = (
+ interaction.options.getMember("user") as GuildMember
+ )
+ .permissionsIn(interaction.channel as Discord.TextChannel)
+ .has("VIEW_CHANNEL");
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "The user's DMs are not open\n\nWhat would you like to do?"
+ )
+ .setStatus("Danger")
+ ],
+ components: [
new MessageActionRow().addComponents([
new Discord.MessageButton()
.setCustomId("log")
@@ -130,76 +220,131 @@
.setStyle(canSeeChannel ? "SECONDARY" : "PRIMARY")
])
]
- }) as Discord.Message;
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ if (component.customId === "here") {
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "You have been warned" +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
+ ],
+ content: `<@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>`,
+ allowedMentions: {
+ users: [
+ (
+ interaction.options.getMember(
+ "user"
+ ) as GuildMember
+ ).id
+ ]
+ }
+ });
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.response
+ ? ` and an appeal ticket was opened in <#${confirmation.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "log") {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("The warn was logged")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "ticket") {
+ const ticketChannel = await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason,
+ "Warn Notification"
+ );
+ if (ticketChannel === null) {
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription("A ticket could not be created")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ }
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ `A ticket was created in <#${ticketChannel}>`
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ }
+ } else {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle("Warn")
.setDescription("No changes were made")
.setStatus("Success")
- ], components: []});
- }
- if ( component.customId === "here" ) {
- await interaction.channel.send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("You have been warned" +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
- ],
- content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
- allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
- });
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ""))
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "log") {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The warn was logged")
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "ticket") {
- const ticketChannel = await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason, "Warn Notification");
- if (ticketChannel === null) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("A ticket could not be created")
- .setStatus("Danger")
- ], components: []});
- }
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription(`A ticket was created in <#${ticketChannel}>`)
- .setStatus("Success")
- ], components: []});
- }
- }
- } else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow warning bots
@@ -207,11 +352,13 @@
// Allow the owner to warn anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow warn
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };