loads of bug fixes
diff --git a/src/commands/categorisationTest.ts b/src/commands/categorisationTest.ts
index a6c7479..f89a899 100644
--- a/src/commands/categorisationTest.ts
+++ b/src/commands/categorisationTest.ts
@@ -1,68 +1,97 @@
-import { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
-import { SlashCommandBuilder } from "@discordjs/builders";
+import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import generateKeyValueList, { toCapitals } from "../utils/generateKeyValueList.js";
-import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js"
+import addPlural from "../utils/plurals.js";
+import getEmojiByName from "../utils/getEmojiByName.js";
const command = new SlashCommandBuilder()
.setName("categorise")
.setDescription("Categorises your servers channels")
const callback = async (interaction: CommandInteraction): Promise<any> => {
- const { renderChannel } = client.logger
-
let channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
let categorised = {}
-
await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading...")
.setEmoji("NUCLEUS.LOADING")
.setStatus("Success")
], ephemeral: true});
+ let predicted = {}
+ let types = {
+ general: ["general", "muted", "main", "topic", "discuss"],
+ commands: ["bot", "command", "music"],
+ images: ["pic", "selfies", "image"],
+ nsfw: ["porn", "nsfw", "sex"],
+ links: ["links"],
+ advertising: ["ads", "advert", "server", "partner"],
+ staff: ["staff", "mod", "admin"],
+ spam: ["spam"],
+ other: ["random"]
+ }
for (let c of channels.values()) {
- let predicted = []
- let types = {
- general: ["general"],
- commands: ["bot", "command", "music"],
- images: ["pic", "selfies", "image"],
- nsfw: ["porn", "nsfw", "sex"],
- links: ["links"],
- advertising: ["ads", "advert", "server", "partner"],
- staff: ["staff", "mod", "admin"]
- }
-
for (let type in types) {
for (let word of types[type]) {
if (c.name.toLowerCase().includes(word)) {
- predicted.push(type)
+ predicted[c.id] = predicted[c.id] ?? []
+ predicted[c.id].push(type)
}
}
}
-
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Categorise")
- .setDescription(generateKeyValueList({
- channel: renderChannel(c),
- category: c.parent ? c.parent.name : "Uncategorised"
- }) + "\n\n" + `Suggested tags: ${predicted.join(", ")}`)
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setStatus("Success")
- ], components: [ new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Use suggested")
- .setStyle("PRIMARY")
- .setCustomId("accept")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- ]), new MessageActionRow().addComponents([new MessageSelectMenu()
- .setPlaceholder("Select a category")
- .setCustomId("category")
- .setMinValues(0)
- .setMaxValues(1)
- .setOptions(Object.keys(types).map(type => {return {label: toCapitals(type), value: type}}))
- ])]});
}
+ let m;
+ for (let c of channels) {
+ // convert channel to a channel if its a string
+ let channel: any
+ console.log(c)
+ if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel).id
+ // @ts-ignore
+ else channel = c[0].id
+ console.log(channel)
+ if (!predicted[channel]) predicted[channel] = []
+ m = await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Categorise")
+ .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
+ .setEmoji("CHANNEL.CATEGORY.CREATE")
+ .setStatus("Success")
+ ], components: [
+ new MessageActionRow().addComponents([new MessageSelectMenu()
+ .setCustomId("selected")
+ .setMaxValues(Object.keys(types).length)
+ .setMinValues(1)
+ .setPlaceholder("Select all types that apply to this channel")
+ .setOptions(Object.keys(types).map(type => ({label: type, value: type})))
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton().setLabel("Accept Suggestion").setCustomId("accept").setStyle("SUCCESS").setDisabled(predicted[channel].length === 0)
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
+ new MessageButton().setLabel("Use \"Other\"").setCustomId("reject").setStyle("SECONDARY")
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
+ ])
+ ]})
+ let i;
+ try {
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ return await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Categorise")
+ .setEmoji("CHANNEL.CATEGORY.DELETE")
+ .setStatus("Danger")
+ .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
+ .setFooter({text: "Message timed out"})
+ ]})
+ }
+ i.deferUpdate()
+ let selected;
+ if (i.customId === "select") { selected = i.values; }
+ if (i.customId === "accept") { selected = predicted[channel]; }
+ if (i.customId === "reject") { selected = ["other"]; }
+ categorised[channel] = selected
+ }
+ console.log(categorised)
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 11c6c79..0239951 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -12,27 +12,34 @@
.setName("ban")
.setDescription("Bans a user from the server")
.addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the ban").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are banned | Default yes").setRequired(false)
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are banned | Default: Yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
- .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default 0").setMinValue(0).setMaxValue(7).setRequired(false))
+ .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<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Ban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "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`
- + `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
- .setColor("Danger")
- .send()
+ let reason = null
+ let confirmation
+ while (true) {
+ 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${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`
+ + `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setColor("Danger")
+ .addReasonButton(reason ?? "")
+ .send(reason !== null)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false
let dm;
@@ -44,7 +51,7 @@
.setEmoji("PUNISH.BAN.RED")
.setTitle("Banned")
.setDescription(`You have been banned in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
+ (reason ? ` for:\n> ${reason}` : "."))
.setStatus("Danger")
],
components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
@@ -58,7 +65,6 @@
} catch {}
try {
let member = (interaction.options.getMember("user") as GuildMember)
- let reason = interaction.options.getString("reason")
member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
reason: reason ?? "No reason provided"
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index c3a4388..b7f4b74 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,6 +1,6 @@
import { HistorySchema } from '../../utils/database';
import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
-import { SlashCommandSubcommandBuilder, SelectMenuOption } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -18,6 +18,7 @@
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"},
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index b1464ee..793a630 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -12,25 +12,32 @@
.setName("kick")
.setDescription("Kicks a user from the server")
.addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the kick").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are kicked | Default yes").setRequired(false)
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are kicked | Default: Yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.KICK.RED")
- .setTitle("Kick")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "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\n`
- + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
- .setColor("Danger")
- .send()
+ let reason = null;
+ let confirmation
+ while (true) {
+ 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${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")
+ .addReasonButton(reason ?? "")
+ .send(reason !== null)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false
let dm;
@@ -42,7 +49,7 @@
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kicked")
.setDescription(`You have been kicked in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
+ (reason ? ` for:\n> ${reason}` : "."))
.setStatus("Danger")
],
components: [new MessageActionRow().addComponents(config.moderation.kick.text ? [new MessageButton()
@@ -55,9 +62,8 @@
}
} catch {}
try {
- (interaction.options.getMember("user") as GuildMember).kick(interaction.options.getString("reason") ?? "No reason provided.")
+ (interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.")
let member = (interaction.options.getMember("user") as GuildMember)
- let reason = interaction.options.getString("reason") ?? null
try { await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason) } catch {}
// @ts-ignore
const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 4c326e7..5e1a18b 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -7,24 +7,23 @@
import keyValueList from "../../utils/generateKeyValueList.js";
import humanizeDuration from "humanize-duration";
import client from "../../utils/client.js";
+import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("mute")
- .setDescription("Mutes a member using Discord's \"Timeout\" feature")
+ .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))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the mute").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are muted | Default yes").setRequired(false)
+ .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))
+ .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): Promise<any> => {
- const { log, NucleusColors, renderUser, entry } = client.logger
+ const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
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,
@@ -119,31 +118,43 @@
], ephemeral: true, fetchReply: true})
}
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Mute")
- .setDescription(keyValueList({
- "user": renderUser(user),
- "time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
- "reason": `\n> ${reason ? reason : "*No reason provided*"}`
- })
- + `The user will be ` + serverSettingsDescription + "\n"
- + `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")
- .send(true)
+ let reason = null;
+ let confirmation;
+ while (true) {
+ 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${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `Are you sure you want to mute <@!${user.id}>?`)
+ .setColor("Danger")
+ .addCustomBoolean(
+ "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
+ async () => await create(interaction.guild, user.user, interaction.user, reason),
+ "An appeal ticket will be created when Confirm is clicked")
+ .addReasonButton(reason ?? "")
+ .send(true)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false
let dm;
let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
+ dm = await user.send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Muted")
.setDescription(`You have been muted in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : ".\n\n" +
+ (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>)`))
.setStatus("Danger")
],
@@ -156,19 +167,36 @@
dmd = true
}
} catch {}
- let member = (interaction.options.getMember("user") as GuildMember)
+ let member = user
+ let errors = 0
try {
if (config.moderation.mute.timeout) {
- member.timeout(muteTime * 1000, interaction.options.getString("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
+ })
+ }
}
- if (config.moderation.mute.role) {
- member.roles.add(config.moderation.mute.role)
- } // make sure this gets removed
- } catch {
+ } 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
+ })
+ }
+ } 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 mute")
+ .setDescription("Something went wrong and the user was not muted")
.setStatus("Danger")
], components: []})
if (dmd) await dm.delete()
@@ -192,10 +220,12 @@
timestamp: new Date().getTime()
},
list: {
- user: entry(member.user.id, renderUser(member.user)),
+ 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)),
- time: entry(muteTime, `${humanizeDuration(muteTime * 1000, {round: true})}`),
- reason: (interaction.options.getString("reason") ? `\n> ${interaction.options.getString("reason")}` : "No reason provided")
+ reason: entry(reason, reason ? reason : '*No reason provided*')
},
hidden: {
guild: interaction.guild.id
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 8dcbf62..f842d76 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -4,7 +4,7 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
+import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -13,7 +13,7 @@
.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))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when their nickname is changed | Default no").setRequired(false)
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when their nickname is changed | Default: No").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
@@ -32,7 +32,7 @@
.setColor("Danger")
.addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.options.getString("reason")),
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, null),
"An appeal ticket will be created when Confirm is clicked")
.send()
if (confirmation.success) {
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index ea4a447..a368e7a 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -12,27 +12,34 @@
.setName("softban")
.setDescription("Kicks a user and deletes their messages")
.addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the softban").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are softbanned | Default yes").setRequired(false)
+ .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are softbanned | Default: Yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
- .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<any> => {
const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "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`
- + `${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")
- .send()
+ let reason = null;
+ let confirmation;
+ while (true) {
+ let 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${interaction.options.getString("notify") === "no" ? ' 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")
+ .addReasonButton(reason ?? "")
+ .send(reason !== null)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false;
let config = await client.database.guilds.read(interaction.guild.id);
@@ -43,7 +50,7 @@
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softbanned")
.setDescription(`You have been softbanned from ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
+ (reason ? ` for:\n> ${reason}` : "."))
.setStatus("Danger")
],
components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
@@ -59,7 +66,7 @@
try {
await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
- reason: interaction.options.getString("reason")
+ reason: reason
});
await interaction.guild.members.unban(member, "Softban");
} catch {
@@ -70,7 +77,7 @@
.setStatus("Danger")
], components: []})
}
- try { await client.database.history.create("softban", interaction.guild.id, member.user, interaction.options.getString("reason")) } catch {}
+ try { await client.database.history.create("softban", interaction.guild.id, member.user, reason) } catch {}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 5a1b67c..d5f4205 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -11,25 +11,32 @@
.setName("unmute")
.setDescription("Unmutes a user")
.addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the unmute").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are unmuted | Default no").setRequired(false)
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are unmuted | Default: No").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
const callback = async (interaction: CommandInteraction): Promise<any> => {
- const { renderUser } = client.logger
+ const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Unmute")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
- })
- + `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")
- .send()
+ let reason = null;
+ let confirmation;
+ while (true) {
+ 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${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")
+ .addReasonButton(reason ?? "")
+ .send(reason !== null)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false
let dm;
@@ -40,15 +47,16 @@
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Unmuted")
.setDescription(`You have been unmuted in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (reason ? ` for:\n> ${reason}` : " with no reason provided."))
.setStatus("Success")
]
})
dmd = true
}
} catch {}
+ let member = (interaction.options.getMember("user") as GuildMember)
try {
- (interaction.options.getMember("user") as GuildMember).timeout(0, interaction.options.getString("reason") || "No reason provided")
+ member.timeout(0, reason || "No reason provided")
} catch {
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
@@ -59,7 +67,27 @@
if (dmd) await dm.delete()
return
}
- try { await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, interaction.options.getString("reason")) } catch {}
+ try { await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, reason) } catch {}
+ let data = {
+ meta: {
+ type: 'memberUnmute',
+ displayName: 'Unmuted',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.green,
+ emoji: "PUNISH.MUTE.GREEN",
+ timestamp: new Date().getTime()
+ },
+ 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)),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data);
let failed = (dmd == false && interaction.options.getString("notify") != "no")
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 370f347..379d49c 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -4,7 +4,7 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
+import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -12,29 +12,37 @@
.setName("warn")
.setDescription("Warns a user")
.addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true))
- .addStringOption(option => option.setName("reason").setDescription("The reason for the warn").setRequired(false))
- .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are warned | Default yes").setRequired(false)
+ .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are warned | Default: Yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
const callback = async (interaction: CommandInteraction): Promise<any> => {
const { log, NucleusColors, renderUser, entry } = client.logger
// TODO:[Modals] Replace this with a modal
- let confirmation = await new confirmationMessage(interaction)
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "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\n`
- + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
- .setColor("Danger")
- .addCustomBoolean(
- "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- 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")
- .send()
+ let reason = null;
+ let confirmation;
+ while (true) {
+ 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${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setColor("Danger")
+ .addCustomBoolean(
+ "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")
+ .addReasonButton(reason)
+ .addReasonButton(reason ?? "")
+ .send(reason !== null)
+ reason = reason ?? ""
+ if (confirmation.newReason === undefined) break
+ reason = confirmation.newReason
+ }
if (confirmation.success) {
let dmd = false
try {
@@ -44,7 +52,7 @@
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warned")
.setDescription(`You have been warned in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : ".") + "\n\n" +
+ (reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
(confirmation.buttonClicked ? `You can appeal this here ticket: <#${confirmation.response}>` : ``))
.setStatus("Danger")
]
@@ -71,7 +79,7 @@
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)),
- reason: (interaction.options.getString("reason") ? `\n> ${interaction.options.getString("reason")}` : "No reason provided")
+ reason: reason ? `\n> ${reason}` : "No reason provided"
},
hidden: {
guild: interaction.guild.id
@@ -80,7 +88,7 @@
try { await client.database.history.create(
"warn", interaction.guild.id,
(interaction.options.getMember("user") as GuildMember).user,
- interaction.user, interaction.options.getString("reason")
+ interaction.user, reason
)} catch {}
log(data);
let failed = (dmd == false && interaction.options.getString("notify") != "no")
@@ -129,7 +137,7 @@
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription(`You have been warned` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
+ (reason ? ` for:\n> ${reason}` : "."))
.setStatus("Danger")
],
content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index eb94de4..5f2cde2 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -3,7 +3,7 @@
import { WrappedCheck } from "jshaiku";
import getEmojiByName from "../../utils/getEmojiByName.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import guide from "../../automations/guide.js";
+import guide from "../../reflex/guide.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index cc6c554..6d62745 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,15 +1,35 @@
-import Discord, { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { testLink, testMalware, testNSFW } from '../utils/scanners.js';
+import { testLink, testMalware, testNSFW } from "../reflex/scanners.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
const command = new SlashCommandBuilder()
.setName("privacy")
- .setDescription("we changed the fucking charger again!")
- .addStringOption(option => option.setName("link").setDescription("fuck you").setRequired(false))
+ .setDescription("Information and options for you and your server's settings")
const callback = async (interaction: CommandInteraction): Promise<any> => {
- console.log(await testLink(interaction.options.getString("link")))
+ let components = [];
+ if (interaction.inCachedGuild() && interaction.member.permissions.has("MANAGE_GUILD")) {
+ components.push(new MessageActionRow().addComponents([new MessageButton()
+ .setLabel("Clear all data")
+ .setEmoji("CONTROL.CROSS")
+ .setCustomId("clear")
+ .setStyle("DANGER")
+ ]));
+ }
+ await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Privacy")
+ .setDescription(
+ "**Link Scanning Types**\n" +
+ "> Facebook - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
+ "> AMP - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
+ "**Transcripts**\n" +
+ "> Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
+ )
+ .setStatus("Success")
+ .setEmoji("NUCLEUS.COMMANDS.LOCK")
+ ], components: components});
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/role/all.ts b/src/commands/role/all.ts
index b2b8c52..7ea7cb6 100644
--- a/src/commands/role/all.ts
+++ b/src/commands/role/all.ts
@@ -114,7 +114,7 @@
count ++;
return (count == 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
(f.inverted ? "**not** " : "") + `${f.name}`
- }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length.toString(), "member")}`)
+ }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success")
], components: [
diff --git a/src/commands/rolemenu.ts b/src/commands/rolemenu.ts
index f53e10a..39e18f7 100644
--- a/src/commands/rolemenu.ts
+++ b/src/commands/rolemenu.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { callback as roleMenu } from "../automations/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js"
const command = new SlashCommandBuilder()
.setName("rolemenu")
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index e664bd0..ba16751 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -16,7 +16,7 @@
.addStringOption(option => option.setName("enabled").setDescription("If users should be able to create tickets").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]]))
.addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
- .addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default 5").setRequired(false).setMinValue(1))
+ .addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default: 5").setRequired(false).setMinValue(1))
.addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false))
const callback = async (interaction: CommandInteraction): Promise<any> => {
@@ -139,7 +139,7 @@
}
}
let data = await client.database.guilds.read(interaction.guild.id);
- data.tickets.customTypes = data.tickets.customTypes.filter((v, i, a) => a.indexOf(v) === i)
+ data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i)
let lastClicked = "";
let embed;
data = {
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index a9f0075..d032598 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { callback as statsChannelAdd } from '../automations/statsChannelAdd.js';
+import { callback as statsChannelAdd } from '../reflex/statsChannelAdd.js';
import client from "../utils/client.js"
const command = new SlashCommandBuilder()
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 15abb0a..5a3371e 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import close from "../../automations/tickets/delete.js";
+import close from "../../actions/tickets/delete.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index c44e576..3d796aa 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import create from "../../automations/tickets/create.js";
+import create from "../../actions/tickets/create.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index da332da..54af9d7 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -163,7 +163,7 @@
const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let tracks = (await client.database.guilds.read(interaction.guild.id)).tracks
- if (!tracks) throw "This server does not have any tracks"
+ if (tracks.length === 0) throw "This server does not have any tracks"
let member = (interaction.member as GuildMember)
// Allow the owner to promote anyone
if (member.id == interaction.guild.ownerId) return true
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index 4ccc807..bd71fe4 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import verify from "../automations/verify.js";
+import verify from "../reflex/verify.js";
const command = new SlashCommandBuilder()
.setName("verify")