loads of new commands, updates and bug fixes
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 1e17e53..8b17db3 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -4,8 +4,8 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js';
import addPlurals from "../../utils/plurals.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -31,13 +31,11 @@
+ `${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")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false
let dm;
- let config = await readConfig(interaction.guild.id);
+ let config = await client.database.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 9dc447b..20fbc01 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -5,7 +5,7 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js'
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -29,13 +29,11 @@
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false
let dm;
- let config = await readConfig(interaction.guild.id);
+ let config = await client.database.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index b2cc94e..854f38f 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -6,7 +6,7 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import humanizeDuration from "humanize-duration";
-import readConfig from "../../utils/readConfig.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -21,7 +21,7 @@
.addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are muted | Default yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]]))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
// @ts-ignore
const { log, NucleusColors, renderUser, entry } = interaction.client.logger
const user = interaction.options.getMember("user") as GuildMember
@@ -32,7 +32,7 @@
minutes: interaction.options.getInteger("minutes") || 0,
seconds: interaction.options.getInteger("seconds") || 0
}
- let config = await readConfig(interaction.guild.id)
+ let config = await client.database.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`
@@ -132,13 +132,11 @@
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ `Are you sure you want to mute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send(true)
if (confirmation.success) {
let dmd = false
let dm;
- let config = await readConfig(interaction.guild.id);
+ let config = await client.database.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 6a0410a..96738c6 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -4,7 +4,6 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js';
import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -31,10 +30,8 @@
.setColor("Danger")
.addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.options.getString("reason")),
"An appeal ticket will be created when Confirm is clicked")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index 924e507..8e6762e 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -19,7 +19,7 @@
.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) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
let user = interaction.options.getMember("user") as GuildMember ?? null
let channel = (interaction.channel as GuildChannel)
if (!(["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(channel.type.toString()))) {
@@ -205,8 +205,6 @@
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
}))
.setColor("Danger")
- // pluralize("day", interaction.options.getInteger("amount"))
- // const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let messages;
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index b91f065..2498746 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -29,8 +29,6 @@
})
+ `Are you sure you want to set the slowmode in this channel?`)
.setColor("Danger")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
try {
@@ -39,7 +37,7 @@
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.SLOWMODE.RED")
.setTitle(`Slowmode`)
- .setDescription("An error occurred while setting the slowmode")
+ .setDescription("Something went wrong while setting the slowmode")
.setStatus("Danger")
], components: []})
}
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 29d3bef..5a01287 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -4,8 +4,8 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js';
-import addPlurals from '../../utils/plurals.js';
+import client from "../../utils/client.js";
+import addPlural from "../../utils/plurals.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -28,15 +28,13 @@
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
- + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\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")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false;
- let config = await readConfig(interaction.guild.id);
+ let config = await client.database.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 8231752..f201142 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -11,7 +11,7 @@
.setDescription("Unbans a user")
.addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true))
-const callback = async (interaction: CommandInteraction) => { // TODO: User search
+const callback = async (interaction: CommandInteraction) => { // TODO: User search UI
let bans = await interaction.guild.bans.fetch()
let user = interaction.options.getString("user")
let resolved = bans.find(ban => ban.user.id == user)
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index b2f8234..2a98c54 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -27,8 +27,6 @@
+ `The user **will${interaction.options.getString("notify") === "yes" ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false
diff --git a/src/commands/mod/unnamed.ts b/src/commands/mod/unnamed.ts
deleted file mode 100644
index ca0bcef..0000000
--- a/src/commands/mod/unnamed.ts
+++ /dev/null
@@ -1,233 +0,0 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
-import keyValueList from "../../utils/generateKeyValueList.js";
-import humanizeDuration from "humanize-duration";
-import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
-import readConfig from '../../utils/readConfig.js'
-
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("unnamed")
- .setDescription("Gives a user a role")
- .addUserOption(option => option.setName("user").setDescription("The user to UNNAMED").setRequired(true)) // TODO
- .addIntegerOption(option => option.setName("days").setDescription("The number of days to UNNAMED the user for | Default 0").setMinValue(0).setMaxValue(27).setRequired(false))
- .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to UNNAMED the user for | Default 0").setMinValue(0).setMaxValue(23).setRequired(false))
- .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to UNNAMED the user for | Default 0").setMinValue(0).setMaxValue(59).setRequired(false))
- .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to UNNAMED the user for | Default 0").setMinValue(0).setMaxValue(59).setRequired(false))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the UNNAMED").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are UNNAMED | Default yes").setRequired(false)
- .addChoices([["Yes", "yes"], ["No", "no"]]))
-
-const callback = async (interaction: CommandInteraction) => {
- // @ts-ignore
- const { log, NucleusColors, renderUser, entry } = interaction.client.logger
- let config = await readConfig(interaction.guild.id);
- const user = interaction.options.getMember("user") as GuildMember
- const reason = interaction.options.getString("reason")
- const time = {
- days: interaction.options.getInteger("days") || 0,
- hours: interaction.options.getInteger("hours") || 0,
- minutes: interaction.options.getInteger("minutes") || 0,
- seconds: interaction.options.getInteger("seconds") || 0
- }
- let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds
- if (muteTime == 0) {
- let m = await interaction.reply({embeds: [
- new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN") // TODO
- .setTitle("UNNAMED")
- .setDescription("How long should the user be UNNAMED")
- .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})
- let component;
- try {
- component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000});
- } catch { return }
- component.deferUpdate();
- if (component.customId == "cancel") return interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED") // TODO
- .setTitle("UNNAMED")
- .setDescription("UNNAMED 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; }
- }
- } else {
- await interaction.reply({embeds: [
- new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN") // TODO
- .setTitle("UNNAMED")
- .setDescription("Loading...")
- .setStatus("Success")
- ], ephemeral: true, fetchReply: true})
- }
- // TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.MUTE.RED") // TODO
- .setTitle("UNNAMED")
- .setDescription(keyValueList({
- "user": `<@!${user.id}> (${user.user.username})`,
- "time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
- "reason": `\n> ${reason ? reason : "*No reason provided*"}`
- })
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
- + `Are you sure you want to mute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`) // TODO
- .setColor("Danger")
- .addCustomBoolean(
- "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
- "An appeal ticket will be created when Confirm is clicked")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()
- if (confirmation.success) {
- let dmd = false
- let dm;
- try {
- if (interaction.options.getString("notify") != "no") {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED") // TODO
- .setTitle("UNNAMED")
- .setDescription(`You have been muted in ${interaction.guild.name}` + // TODO
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("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>)`)) // TODO
- .setStatus("Danger")
- ]
- })
- dmd = true
- }
- } catch {}
- try {
- await ((interaction.options.getMember("user") as GuildMember).roles.add(interaction.guild.roles.cache.find((r) => r.id === config.moderation.role.role)))
- // TODO: Store when to remove the role
- } catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle(`Mute`)
- .setDescription("Something went wrong and the user was not UNNAMED")
- .setStatus("Danger")
- ], components: []})
- if (dmd) await dm.delete()
- return
- }
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`) // TODO
- .setTitle(`Mute`) // TODO
- .setDescription("The member was muted" + (failed ? ", but could not be notified" : "")) // TODO
- .setStatus(failed ? "Warning" : "Success")
- ], components: []})
- let data = {
- meta:{
- type: 'memberMute', // TODO
- displayName: 'Member Muted', // TODO
- calculateType: 'guildMemberPunish',
- color: NucleusColors.yellow,
- emoji: 'PUNISH.WARN.YELLOW', // TODO
- timestamp: new Date().getTime()
- },
- list: {
- user: entry((interaction.options.getMember("user") as GuildMember).user.id, renderUser((interaction.options.getMember("user") as GuildMember).user)),
- mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)), // TODO
- time: entry(muteTime, `${humanizeDuration(muteTime * 1000, {round: true})}`),
- reason: (interaction.options.getString("reason") ? `\n> ${interaction.options.getString("reason")}` : "No reason provided")
- },
- hidden: {
- guild: interaction.guild.id
- }
- }
- log(data, interaction.client);
- } else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN") // TODO
- .setTitle(`Mute`) // TODO
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []})
- }
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as GuildMember)
- let me = (interaction.guild.me as GuildMember)
- let apply = (interaction.options.getMember("user") as GuildMember)
- if (member == null || me == null || apply == null) throw "That member is not in the server"
- let memberPos = member.roles ? member.roles.highest.position : 0
- let mePos = me.roles ? me.roles.highest.position : 0
- let applyPos = apply.roles ? apply.roles.highest.position : 0
- // Check if Nucleus can UNNAMED the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
- // Check if Nucleus has permission to UNNAMED
- if (! me.permissions.has("MANAGE_ROLES")) throw "I do not have the `manage_roles` permission";
- // Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
- // Do not allow muting Nucleus
- if (member.id == me.id) throw "I cannot UNNAMED myself"
- // Allow the owner to UNNAMED 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";
- // Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
- // Allow UNNAMED
- return true
-}
-
-export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 715777e..46e2871 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -16,7 +16,7 @@
.addChoices([["Yes", "yes"], ["No", "no"]])
)
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
// @ts-ignore
const { log, NucleusColors, renderUser, entry } = interaction.client.logger
// TODO:[Modals] Replace this with a modal
@@ -32,10 +32,8 @@
.setColor("Danger")
.addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.options.getString("reason")),
"An appeal ticket will be created when Confirm is clicked")
-// pluralize("day", interaction.options.getInteger("delete"))
-// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
let dmd = false