i have not committed in years
diff --git a/src/automations/statsChannelRemove.ts b/src/automations/statsChannelRemove.ts
index 42ec580..4b24768 100644
--- a/src/automations/statsChannelRemove.ts
+++ b/src/automations/statsChannelRemove.ts
@@ -1,8 +1,9 @@
import log from '../utils/log.js'
import readConfig from '../utils/readConfig.js'
import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
+import singleNotify from '../utils/singleNotify.js';
-export async function callback(_, member) {
+export async function callback(interaction, member) {
let config = await readConfig(member.guild.id);
config.stats.forEach(async element => {
@@ -13,7 +14,12 @@
let channel = await member.client.channels.fetch(element.channel)
if (channel.guild.id !== member.guild.id) return
- if (!channel) return // TODO: Notify mods
+ if (!channel) return await singleNotify(interaction.client,
+ "statsChannelDeleted",
+ member.guild.id,
+ "The stats channel has been deleted. Please set a new channel to use this feature.",
+ "Critical"
+ )
try {
await channel.edit({ name: string })
} catch (err) {
diff --git a/src/automations/unscan.ts b/src/automations/unscan.ts
index 1fb47f8..743374b 100644
--- a/src/automations/unscan.ts
+++ b/src/automations/unscan.ts
@@ -1,10 +1,12 @@
import * as scan from '../utils/scanners.js'
+import Tesseract from 'tesseract.js';
export async function LinkCheck(message): Promise<boolean> {
let links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []
let detections = []
const promises = links.map(async element => {
try {
+ if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return // Also matches discord.net, not enough of a bug
element = await scan.testLink(element)
} catch {}
detections.push({tags: element.tags || [], safe: element.safe})
@@ -27,9 +29,9 @@
export async function NSFWCheck(element): Promise<boolean> {
try {
+ let test = (await scan.testNSFW(element))
//@ts-ignore
- let test = (await scan.testNSFW(element)).nsfw
- return test
+ return test.nsfw
} catch {
return false
}
@@ -64,4 +66,8 @@
}
}
return "none"
+}
+
+export async function TestImage(element): Promise<string> {
+ return "";
}
\ No newline at end of file
diff --git a/src/automations/welcome.ts b/src/automations/welcome.ts
index 6505265..09e03d3 100644
--- a/src/automations/welcome.ts
+++ b/src/automations/welcome.ts
@@ -17,7 +17,6 @@
}
}
-
if (!config.welcome.verificationRequired.message && config.welcome.channel) {
let string = config.welcome.message
if (string) {
@@ -32,7 +31,7 @@
} else {
let channel = await member.client.channels.fetch(config.welcome.channel)
if (channel.guild.id !== member.guild.id) return
- if (!channel) return // TODO: Notify mods
+ if (!channel) return
try {
await channel.send(string)
} catch (err) {
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 92ed3a7..e94035e 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,9 +1,10 @@
-import { CommandInteraction, GuildMember } from "discord.js";
+import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
+import readConfig from '../../utils/readConfig.js'
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -18,7 +19,7 @@
const callback = async (interaction: CommandInteraction) => {
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
.setDescription(keyValueList({
@@ -31,19 +32,26 @@
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()) {
+ .send()
+ if (confirmation.success) {
let dmd = false
let dm;
+ let config = await readConfig(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.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")}` : "."))
.setStatus("Danger")
- ]
+ ],
+ components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ] : [])]
})
dmd = true
}
@@ -54,7 +62,7 @@
reason: interaction.options.getString("reason") ?? "No reason provided"
})
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle(`Ban`)
.setDescription("Something went wrong and the user was not banned")
@@ -64,14 +72,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.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()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.BAN.GREEN")
.setTitle(`Ban`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 08beaa5..34a1571 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,9 +1,10 @@
-import { CommandInteraction, GuildMember } from "discord.js";
+import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
+import readConfig from '../../utils/readConfig.js'
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -17,7 +18,7 @@
const callback = async (interaction: CommandInteraction) => {
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kick")
.setDescription(keyValueList({
@@ -29,19 +30,26 @@
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()) {
+ .send()
+ if (confirmation.success) {
let dmd = false
let dm;
+ let config = await readConfig(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.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")}` : "."))
.setStatus("Danger")
- ]
+ ],
+ components: [new MessageActionRow().addComponents(config.moderation.kick.text ? [new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.kick.text)
+ .setURL(config.moderation.kick.link)
+ ] : [])]
})
dmd = true
}
@@ -49,7 +57,7 @@
try {
(interaction.options.getMember("user") as GuildMember).kick(interaction.options.getString("reason") ?? "No reason provided.")
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
.setTitle(`Kick`)
.setDescription("Something went wrong and the user was not kicked")
@@ -59,14 +67,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.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()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.KICK.GREEN")
.setTitle(`Kick`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/lock.ts b/src/commands/mod/lock.ts
index dbc7b6c..9199cd4 100644
--- a/src/commands/mod/lock.ts
+++ b/src/commands/mod/lock.ts
@@ -8,7 +8,7 @@
.setDescription("Manages a lock on a channel")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [mod/lock]");
+ interaction.reply("This command is not yet finished [mod/lock]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 02d2531..165d906 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,11 +1,13 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+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
@@ -17,11 +19,13 @@
.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 kicked | Default yes").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"]]))
// TODO: notify the user when the mute is lifted
const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { log, NucleusColors, renderUser, entry } = interaction.client.logger
const user = interaction.options.getMember("user") as GuildMember
const reason = interaction.options.getString("reason")
const time = {
@@ -33,7 +37,7 @@
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 EmojiEmbed()
+ new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Mute")
.setDescription("How long should the user be muted")
@@ -88,7 +92,7 @@
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 EmojiEmbed()
+ if (component.customId == "cancel") return interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
.setDescription("Mute cancelled")
@@ -106,7 +110,7 @@
}
} else {
await interaction.reply({embeds: [
- new EmojiEmbed()
+ new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Mute")
.setDescription("Loading...")
@@ -114,7 +118,7 @@
], ephemeral: true, fetchReply: true})
}
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
.setDescription(keyValueList({
@@ -127,20 +131,27 @@
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send(true)) {
+ .send(true)
+ if (confirmation.success) {
let dmd = false
let dm;
+ let config = await readConfig(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.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" +
`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")
- ]
+ ],
+ components: [new MessageActionRow().addComponents(config.moderation.mute.text ? [new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.mute.text)
+ .setURL(config.moderation.mute.link)
+ ] : [])]
})
dmd = true
}
@@ -148,24 +159,44 @@
try {
(interaction.options.getMember("user") as GuildMember).timeout(muteTime * 1000, interaction.options.getString("reason") || "No reason provided")
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle(`Mute`)
- .setDescription("Something went wrong and the user was not kicked")
+ .setDescription("Something went wrong and the user was not mute")
.setStatus("Danger")
], components: []})
if (dmd) await dm.delete()
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Mute`)
.setDescription("The member was muted" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
], components: []})
+ let data = {
+ meta:{
+ type: 'memberMute',
+ displayName: 'Member Muted',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.yellow,
+ emoji: 'PUNISH.WARN.YELLOW',
+ 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)),
+ 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 EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle(`Mute`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index d23751c..9584055 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,25 +1,108 @@
-import { CommandInteraction, GuildMember } from "discord.js";
+import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.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) =>
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").setRequired(false))
+ .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)
.addChoices([["Yes", "yes"], ["No", "no"]])
)
const callback = async (interaction: CommandInteraction) => {
+ // TODO:[Modals] Replace this with a modal
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("PUNISH.NICKNAME.RED")
+ .setTitle("Nickname")
+ .setDescription(keyValueList({
+ "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
+ })
+ + `The user **will${interaction.options.getString("notify") == "yes" ? '' : ' 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")
+ .addCustomCallback(
+ "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
+ () => { create(interaction.guild, interaction.options.getUser("user"), interaction.client)},
+ "An appeal ticket was created")
+// 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") == "yes") {
+ dm = await (interaction.options.getMember("user") as GuildMember).send({
+ embeds: [new generateEmojiEmbed()
+ .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.buttonClicked ? `You can appeal this in this ticket: <#${confirmation.response}>` : ``))
+ .setStatus("Danger")
+ ]
+ })
+ dmd = true
+ }
+ } catch {}
+ try {
+ (interaction.options.getMember("user") as GuildMember).setNickname(interaction.options.getString("name") ?? null, "Nucleus Nickname command")
+ } catch {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .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
+ }
+ let failed = (dmd == false && interaction.options.getString("notify") == "yes")
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle(`Nickname`)
+ .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : ""))
+ .setStatus(failed ? "Warning" : "Success")
+ ], components: []})
+ } else {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setTitle(`Nickname`)
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ], components: []})
+ }
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
+ 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 change the nickname
+ if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+ // Check if Nucleus has permission to change the nickname
+ if (! interaction.guild.me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the `manage_nicknames` permission";
+ // Allow the owner to change anyone's nickname
+ if ((interaction.member as GuildMember).id == interaction.guild.ownerId) return true
+ // Check if the user has manage_nicknames permission
+ if (! (interaction.member as GuildMember).permissions.has("MANAGE_NICKNAMES")) throw "You do not have the `manage_nicknames` 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 change
+ return true
}
export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index aa2f405..29c228f 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -2,9 +2,10 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
+import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -16,23 +17,16 @@
.setRequired(false)
.setMinValue(1)
.setMaxValue(100))
- .addChannelOption(option => option.setName("channel").setDescription("The channel to purge messages from").setRequired(false))
.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) => {
let user = interaction.options.getMember("user") as GuildMember ?? null
- let channel = (interaction.options.getChannel("channel") as GuildChannel) ?? interaction.channel
- let thischannel
- if ((interaction.options.getChannel("channel") as GuildChannel) == null) {
- thischannel = true
- } else {
- thischannel = (interaction.options.getChannel("channel") as GuildChannel).id == interaction.channel.id
- }
+ let 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()
+ new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("You cannot purge this channel")
@@ -46,7 +40,7 @@
if ( !interaction.options.getInteger("amount") ) {
await interaction.reply({
embeds: [
- new EmojiEmbed()
+ new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("Select how many messages to delete")
@@ -60,7 +54,7 @@
while (true) {
let m = await interaction.editReply({
embeds: [
- new EmojiEmbed()
+ new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("Select how many messages to delete. You can continue clicking until all messages are cleared.")
@@ -119,12 +113,11 @@
}
messages = await (channel as TextChannel).bulkDelete(ms, true);
})
- deleted = deleted.concat(messages.map(m => m)) // TODO: .values doesnt work so using .map
- // TODO: Support for users
+ deleted = deleted.concat(messages.map(m => m))
}
if (deleted.length === 0) return await interaction.editReply({
embeds: [
- new EmojiEmbed()
+ new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("No messages were deleted")
@@ -147,7 +140,7 @@
description: "Purge log"
}
} catch {}
- let m = await interaction.editReply({embeds: [new EmojiEmbed()
+ let m = await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`CHANNEL.PURGE.GREEN`)
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -164,14 +157,14 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000});
} catch {}
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
+ interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Uploaded")
.setStatus("Success")
], components: [], files: [attachmentObject]})
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
+ interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -180,29 +173,31 @@
}
return
} else {
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription(keyValueList({
- "channel": `<#${channel.id}> (${(channel as GuildChannel).name})` + (thischannel ? " [This channel]" : ""),
+ "channel": `<#${channel.id}> (${(channel as GuildChannel).name})` + ("[This channel]"),
"amount": interaction.options.getInteger("amount").toString(),
"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()) {
+ .send()
+ if (confirmation.success) {
let messages;
try {
- (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")}).then(async (ms) => {
- if (user) {
- ms = ms.filter(m => m.author.id === user.id)
- }
- messages = await (channel as TextChannel).bulkDelete(ms, true);
- }) // TODO: fix for purge amount by user, not just checking x
+ if (!user) {
+ let toDelete = await (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")})
+ messages = await (channel as TextChannel).bulkDelete(toDelete, true);
+ } else {
+ let 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) {
- console.log(e)
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle(`Purge`)
.setDescription("Something went wrong and no messages were deleted")
@@ -224,7 +219,7 @@
description: `Purge log`
}
} catch {}
- let m = await interaction.editReply({embeds: [new EmojiEmbed()
+ let m = await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`CHANNEL.PURGE.GREEN`)
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -241,14 +236,14 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000});
} catch {}
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new EmojiEmbed()
+ interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
- .setDescription("Uploaded")
+ .setDescription("Transcript uploaded above")
.setStatus("Success")
], components: [], files: [attachmentObject]})
} else {
- interaction.editReply({embeds: [new EmojiEmbed()
+ interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -256,7 +251,7 @@
], components: []})
}
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 52ab1bd..8f6f323 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -8,7 +8,7 @@
.setDescription("Manages slowmode in a channel")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [mod/slowmode]");
+ interaction.reply("This command is not yet finished [mod/slowmode]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 233b7f2..44d425a 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,9 +1,10 @@
-import { CommandInteraction, GuildMember } from "discord.js";
+import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
+import readConfig from '../../utils/readConfig.js'
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -11,14 +12,14 @@
.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 banbanned | Default yes").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) => {
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
.setDescription(keyValueList({
@@ -31,18 +32,25 @@
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()) {
- let dmd = false
+ .send()
+ if (confirmation.success) {
+ let dmd = false;
+ let config = await readConfig(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.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")}` : "."))
.setStatus("Danger")
- ]
+ ],
+ components: [new MessageActionRow().addComponents(config.moderation.ban.text ? [new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ] : [])]
})
dmd = true
}
@@ -54,7 +62,7 @@
});
await interaction.guild.members.unban(interaction.options.getMember("user") as GuildMember, "Softban");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle(`Softban`)
.setDescription("Something went wrong and the user was not softbanned")
@@ -62,14 +70,14 @@
], components: []})
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.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()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.BAN.GREEN")
.setTitle(`Softban`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 6477bb3..3ffc001 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -8,7 +8,7 @@
.setDescription("Unbans a user")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [mod/unban]");
+ interaction.reply("This command is not yet finished [mod/unban]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 2c522a4..65e5e97 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -17,7 +17,7 @@
const callback = async (interaction: CommandInteraction) => {
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Unmute")
.setDescription(keyValueList({
@@ -29,13 +29,14 @@
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()) {
+ .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 EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Unmuted")
.setDescription(`You have been unmuted in ${interaction.guild.name}` +
@@ -49,7 +50,7 @@
try {
(interaction.options.getMember("user") as GuildMember).timeout(0, interaction.options.getString("reason") || "No reason provided")
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle(`Unmute`)
.setDescription("Something went wrong and the user was not unmuted")
@@ -59,14 +60,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.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()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle(`Unmute`)
.setDescription("No changes were made")
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index c7bd4b1..5f7c7de 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,4 @@
-import { CommandInteraction } from "discord.js";
+import { CategoryChannel, CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -6,9 +6,13 @@
builder
.setName("viewas")
.setDescription("View the server as a specific member")
+ .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true))
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [mod/viewas]");
+ let channels = interaction.guild.channels.cache
+ .filter(c => c.type === "GUILD_CATEGORY")
+ .map(c => (c as CategoryChannel).children.map(c => c))
+ console.log(channels)
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 3662896..d89a778 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -2,8 +2,9 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
+import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -17,9 +18,9 @@
const callback = async (interaction: CommandInteraction) => {
// @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
+ const { log, NucleusColors, renderUser, entry } = interaction.client.logger
// TODO:[Modals] Replace this with a modal
- if (await new confirmationMessage(interaction)
+ let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
.setDescription(keyValueList({
@@ -29,25 +30,31 @@
+ `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")
+ .addCustomCallback(
+ "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
+ () => { create(interaction.guild, interaction.options.getUser("user"), interaction.client)},
+ "An appeal ticket was created")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
- .send()) {
+ .send()
+ if (confirmation.success) {
let dmd = false
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.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")}` : "."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : ".") + "\n\n" +
+ (confirmation.buttonClicked ? `You can appeal this in this ticket: <#${confirmation.response}>` : ``))
.setStatus("Danger")
]
})
dmd = true
}
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle(`Warn`)
.setDescription("Something went wrong and the user was not warned")
@@ -64,8 +71,8 @@
timestamp: new Date().getTime()
},
list: {
- user: renderUser((interaction.options.getMember("user") as GuildMember).user.id, (interaction.options.getMember("user") as GuildMember).user),
- warnedBy: renderUser(interaction.member.user.id, 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: (interaction.options.getString("reason") ? `\n> ${interaction.options.getString("reason")}` : "No reason provided")
},
hidden: {
@@ -75,7 +82,7 @@
log(data, interaction.client);
let failed = (dmd == false && interaction.options.getString("notify") != "no")
if (!failed) {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The user was warned")
@@ -83,7 +90,7 @@
], components: []})
} else {
let m = await interaction.editReply({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription("The user's DMs are not open\n\nWhat would you like to do?")
@@ -106,7 +113,7 @@
try {
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000});
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("No changes were made")
@@ -115,7 +122,7 @@
}
if ( component.customId == "here" ) {
await interaction.channel.send({
- embeds: [new EmojiEmbed()
+ embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription(`You have been warned` +
@@ -125,14 +132,14 @@
content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
})
- return await interaction.editReply({embeds: [new EmojiEmbed()
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The user was warned")
.setStatus("Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The warn was logged")
@@ -141,7 +148,7 @@
}
}
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle(`Warn`)
.setDescription("No changes were made")
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 43a5fd7..ab23bf7 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,5 +1,6 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { WrappedCheck } from "jshaiku";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -7,8 +8,27 @@
.setName("ping")
.setDescription("Gets the bot's ping time")
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [nucleus/ping]");
+const callback = async (interaction: CommandInteraction) => {
+ // WEBSOCKET | Nucleus -> Discord
+ // EDITING | Nucleus -> discord -> nucleus | edit time / 2
+ let initial = new Date().getTime();
+ await interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("Ping")
+ .setDescription(`Checking ping times...`)
+ .setEmoji("NUCLEUS.LOADING")
+ .setStatus("Danger")
+ ], ephemeral: true});
+ let ping = new Date().getTime() - initial;
+ interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Ping")
+ .setDescription(
+ `**Ping:** \`${ping}ms\`\n` +
+ `**To Discord:** \`${interaction.client.ws.ping}ms\`\n` +
+ `**From Expected:** \`±${Math.abs((ping / 2) - interaction.client.ws.ping)}ms\``
+ )
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
+ .setStatus("Danger")
+ ]})
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index 7f468fa..c12b950 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -1,14 +1,26 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("stats")
- .setDescription("Gets the bot's statse")
+ .setDescription("Gets the bot's stats")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [nucleus/stats]");
+ interaction.reply({
+ embeds: [new generateEmojiEmbed()
+ .setTitle("Stats")
+ .setDescription(
+ `**Servers:** ${interaction.client.guilds.cache.size}\n` +
+ `**Ping:** \`${interaction.client.ws.ping*2}ms\``
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.GRAPHS")
+
+ ], ephemeral: true
+ });
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index e76d49f..36338dc 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -1,14 +1,50 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("suggest")
.setDescription("Sends a suggestion to the developers")
+ .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [nucleus/suggest]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { renderUser } = interaction.client.logger
+ let suggestion = interaction.options.getString("suggestion");
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("ICONS.OPP.ADD")
+ .setTitle("Suggest")
+ .setDescription(`**Suggestion:**\n> ${suggestion}\n`
+ + `Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?`)
+ .setColor("Danger")
+ .send()
+ if (confirmation.success) {
+ await (interaction.client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
+ embeds: [
+ new generateEmojiEmbed()
+ .setTitle(`Suggestion`)
+ .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOGO")
+ ]
+ })
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("ICONS.ADD")
+ .setTitle(`Suggest`)
+ .setDescription("Your suggestion was sent successfully")
+ .setStatus("Success")
+ ], components: []})
+ } else {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("ICONS.OPP.ADD")
+ .setTitle(`Suggest`)
+ .setDescription("No changes were made")
+ .setStatus("Danger")
+ ], components: []})
+ }
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 063f195..3174421 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,4 +1,4 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import { testLink, testMalware, testNSFW } from '../utils/scanners.js';
diff --git a/src/commands/role/all.ts b/src/commands/role/all.ts
index 0f4c43f..44e77fd 100644
--- a/src/commands/role/all.ts
+++ b/src/commands/role/all.ts
@@ -8,7 +8,7 @@
.setDescription("Gives or removes a role from everyone")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [role/all]");
+ interaction.reply("This command is not yet finished [role/all]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index 4229133..b45e1d1 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -5,10 +5,10 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("user")
- .setDescription("Gives or removes a role form someone")
+ .setDescription("Gives or removes a role from someone")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [role/user]");
+ interaction.reply("This command is not yet finished [role/user]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/server.ts b/src/commands/server.ts
deleted file mode 100644
index 27d0373..0000000
--- a/src/commands/server.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-
-const command = new SlashCommandBuilder()
- .setName("server")
- .setDescription("Shows info about the server")
-
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [server]");
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
diff --git a/src/commands/settings/automation.ts b/src/commands/settings/automation.ts
index 3874f7f..0053f76 100644
--- a/src/commands/settings/automation.ts
+++ b/src/commands/settings/automation.ts
@@ -8,7 +8,7 @@
.setDescription("Shows all automation options")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/automation]");
+ interaction.reply("This command is not yet finished [settings/automation]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/log/channel.ts b/src/commands/settings/log/channel.ts
index af570a7..5843438 100644
--- a/src/commands/settings/log/channel.ts
+++ b/src/commands/settings/log/channel.ts
@@ -8,7 +8,7 @@
.setDescription("Sets the log channel")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/log/channel]");
+ interaction.reply("This command is not yet finished [settings/log/channel]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/log/events.ts b/src/commands/settings/log/events.ts
index 4f4c9bd..dac200c 100644
--- a/src/commands/settings/log/events.ts
+++ b/src/commands/settings/log/events.ts
@@ -8,7 +8,7 @@
.setDescription("Sets what events should be logged")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/log/events]");
+ interaction.reply("This command is not yet finished [settings/log/events]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/log/ignore.ts b/src/commands/settings/log/ignore.ts
index eea7048..1b4d245 100644
--- a/src/commands/settings/log/ignore.ts
+++ b/src/commands/settings/log/ignore.ts
@@ -8,7 +8,7 @@
.setDescription("Sets which users, channels and roles should be ignored")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/log/ignore]");
+ interaction.reply("This command is not yet finished [settings/log/ignore]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/log/ignored.ts b/src/commands/settings/log/ignored.ts
index df5f7b6..bf4a30c 100644
--- a/src/commands/settings/log/ignored.ts
+++ b/src/commands/settings/log/ignored.ts
@@ -8,7 +8,7 @@
.setDescription("Gets the ignored users, channels and roles")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/log/ignored]");
+ interaction.reply("This command is not yet finished [settings/log/ignored]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/menu.ts b/src/commands/settings/menu.ts
index c7269c7..9950fe4 100644
--- a/src/commands/settings/menu.ts
+++ b/src/commands/settings/menu.ts
@@ -35,13 +35,13 @@
}
let toLogDropdown = new MessageSelectMenu()
- .setCustomId("tolog")
+ .setCustomId("log")
.setMaxValues(22)
.addOptions()
let embed = new MessageEmbed()
- interaction.reply("Command incomplete [settings/all]");
+ interaction.reply("This command is not yet finished [settings/all]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/mod/_meta.ts b/src/commands/settings/mod/_meta.ts
index 713bb48..9c3cd62 100644
--- a/src/commands/settings/mod/_meta.ts
+++ b/src/commands/settings/mod/_meta.ts
@@ -1,4 +1,4 @@
-const name = "announcements";
-const description = "Settings for mod messages";
+const name = "warnings";
+const description = "Settings for mod warnings";
export { name, description };
\ No newline at end of file
diff --git a/src/commands/settings/mod/channel.ts b/src/commands/settings/mod/channel.ts
index 16230ba..88c8396 100644
--- a/src/commands/settings/mod/channel.ts
+++ b/src/commands/settings/mod/channel.ts
@@ -8,7 +8,7 @@
.setDescription("Sets the channel for staff messages to go to")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/mod/channel]");
+ interaction.reply("This command is not yet finished [settings/mod/channel]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/mod/events.ts b/src/commands/settings/mod/events.ts
index 3dc5e99..be5de57 100644
--- a/src/commands/settings/mod/events.ts
+++ b/src/commands/settings/mod/events.ts
@@ -8,7 +8,7 @@
.setDescription("Sets which events mods should be notified about")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/mod/events]");
+ interaction.reply("This command is not yet finished [settings/mod/events]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 2c2b806..64dc980 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -14,7 +14,7 @@
.addRoleOption(option => option.setName("supportping").setDescription("The role pinged when a ticket is created").setRequired(false))
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/tickets]");
+ interaction.reply("This command is not yet finished [settings/tickets]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/verify/channel.ts b/src/commands/settings/verify/channel.ts
deleted file mode 100644
index ad881c2..0000000
--- a/src/commands/settings/verify/channel.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("channel")
- .setDescription("Sets the verify channel")
-
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/verify/channel]");
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
diff --git a/src/commands/settings/verify/role.ts b/src/commands/settings/verify/role.ts
index 3082c71..c4de7af 100644
--- a/src/commands/settings/verify/role.ts
+++ b/src/commands/settings/verify/role.ts
@@ -8,7 +8,7 @@
.setDescription("Sets the role given after verifying")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/verify/role]");
+ interaction.reply("This command is not yet finished [settings/verify/role]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 9a10f5a..a5fcfc1 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -7,7 +7,7 @@
.setDescription("Get and manage the servers tags")
const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [tag]");
+ interaction.reply("This command is not yet finished [tag]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 7b9d1c2..237623d 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -1,9 +1,7 @@
-import Discord, { CommandInteraction } from "discord.js";
+import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import readConfig from "../../utils/readConfig.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
+import close from "../../automations/tickets/delete.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -11,89 +9,7 @@
.setDescription("Closes a ticket")
const callback = async (interaction: CommandInteraction) => {
- // @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
-
- let config = await readConfig(interaction.guild.id);
- let channel = (interaction.channel as Discord.TextChannel)
- if (config.tickets.category != channel.parent.id) {
- return interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket is not in your tickets category, so cannot be deleted.")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
- }
- let status = channel.topic.split(" ")[1];
- if (status == "Archived") {
- interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket will be deleted in 3 seconds.")
- .setStatus("Danger")
- .setEmoji("GUILD.TICKET.CLOSE")
- ]});
- setTimeout(async () => {
- let data = {
- meta:{
- type: 'ticketClosed',
- displayName: 'Ticket Closed',
- calculateType: true,
- color: NucleusColors.red,
- emoji: 'GUILD.TICKET.CLOSE',
- timestamp: new Date().getTime()
- },
- list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- closedAt: entry(new Date().getTime(), renderDelta(new Date().getTime()))
- },
- hidden: {
- guild: interaction.guild.id
- }
- }
- log(data, interaction.client);
- interaction.channel.delete();
- }, 3000);
- return;
- } else if (status == "Active") {
- interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket will be archived in 3 seconds.")
- .setStatus("Warning")
- .setEmoji("GUILD.TICKET.ARCHIVED")
- ]});
- setTimeout(async () =>{
- channel.permissionsFor(await interaction.guild.members.fetch(channel.topic.split(" ")[0])).remove("VIEW_CHANNEL");
- channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
- let data = {
- meta:{
- type: 'ticketArchive',
- displayName: 'Ticket Archived',
- calculateType: true,
- color: NucleusColors.yellow,
- emoji: 'GUILD.TICKET.ARCHIVED',
- timestamp: new Date().getTime()
- },
- list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- archivedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- archivedAt: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- ticketChannel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: interaction.guild.id
- }
- }
- log(data, interaction.client);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket has been archived.\nType `/ticket close` to delete it.")
- .setStatus("Warning")
- .setEmoji("GUILD.TICKET.ARCHIVED") // TODO:[Premium] Add a transcript option ||\----/|| <- the bridge we will cross when we come to it
- ]});
- }, 3000);
- return;
- }
+ await close(interaction);
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 4f58aa0..6567c49 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -1,15 +1,7 @@
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import { tickets, toHexArray, toHexInteger } from "../../utils/calculate.js";
-import readConfig from "../../utils/readConfig.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
-
-function capitalize(s: string) {
- s = s.replace(/([A-Z])/g, ' $1');
- return s.length < 3 ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
-}
+import create from "../../automations/tickets/create.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -18,155 +10,7 @@
.addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false))
const callback = async (interaction: CommandInteraction) => {
- // @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
-
- let config = await readConfig(interaction.guild.id);
- if (!config.tickets.enabled || !config.tickets.category) {
- return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Tickets are disabled")
- .setDescription("Please enable tickets in the configuration to use this command.")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
- }
- let category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
- let count = 0;
- category.children.forEach(element => {
- if (!(element.type == "GUILD_TEXT")) return;
- if ((element as Discord.TextChannel).topic.includes(`${interaction.member.user.id}`)) {
- if ((element as Discord.TextChannel).topic.endsWith("Active")) {
- count++;
- }
- }
- });
- if (count >= config.tickets.maxTickets) {
- return await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Create Ticket")
- .setDescription(`You have reached the maximum amount of tickets (${config.tickets.maxTickets}). Please close one of your active tickets before creating a new one.`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
- }
- let ticketTypes
- if (config.tickets.customTypes) ticketTypes = config.tickets.customTypes;
- else if (config.tickets.types) ticketTypes = toHexArray(config.tickets.types, tickets);
- else ticketTypes = [];
- let chosenType;
- if (ticketTypes.length > 0) {
- let splitFormattedTicketTypes = [];
- let formattedTicketTypes = [];
- formattedTicketTypes = ticketTypes.map(type => {
- return new MessageButton()
- .setLabel(capitalize(type))
- .setStyle("PRIMARY")
- .setCustomId(type)
- .setEmoji(getEmojiByName(("TICKETS." + type.toString().toUpperCase()), "id"));
- });
- for (let i = 0; i < formattedTicketTypes.length; i += 4) {
- splitFormattedTicketTypes.push(new MessageActionRow().addComponents(formattedTicketTypes.slice(i, i + 4)));
- }
- let m = await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Create Ticket")
- .setDescription("Please select a ticket type")
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], ephemeral: true, fetchReply: true, components: splitFormattedTicketTypes});
- let component;
- try {
- component = await (m as Discord.Message).awaitMessageComponent({time: 2.5 * 60 * 1000});
- } catch (e) {
- return;
- }
- component.deferUpdate();
- chosenType = component.customId;
- } else {
- chosenType = null
- await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Create Ticket")
- .setEmoji("GUILD.TICKET.OPEN")
- ], ephemeral: true})
- }
- let overwrites = [{
- id: interaction.member,
- allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
- type: "member"
- }] as Discord.OverwriteResolvable[];
- if (config.tickets.supportRole != null) {
- overwrites.push({
- id: interaction.guild.roles.cache.get(config.tickets.supportRole),
- allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
- type: "role"
- })
- }
-
- let c;
- try {
- c = await interaction.guild.channels.create(interaction.member.user.username, {
- type: "GUILD_TEXT",
- topic: `${interaction.member.user.id} Active`,
- parent: config.tickets.category,
- nsfw: false,
- permissionOverwrites: (overwrites as Discord.OverwriteResolvable[]),
- reason: "Creating ticket"
- })
- } catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Create Ticket")
- .setDescription("Failed to create ticket")
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- }
- try {
- await c.send(
- {
- content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
- allowedMentions: {
- users: [(interaction.member as Discord.GuildMember).id],
- roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
- }
- }
- )
- let content = interaction.options.getString("message") || "";
- if (content) content = `**Message:**\n> ${content}\n`;
- await c.send({ embeds: [new EmojiEmbed()
- .setTitle("New Ticket")
- .setDescription(
- `Ticket created by <@${interaction.member.user.id}>\n` +
- `**Support type:** ${chosenType != null ? (getEmojiByName("TICKETS." + chosenType.toUpperCase()) + " " + capitalize(chosenType)) : "General"}\n` +
- `**Ticket ID:** \`${c.id}\`\n${content}\n` +
- `Type \`/ticket close\` to archive this ticket.`,
- )
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ]})
- let data = {
- meta:{
- type: 'ticketCreate',
- displayName: 'Ticket Created',
- calculateType: true,
- color: NucleusColors.green,
- emoji: 'GUILD.TICKET.OPEN',
- timestamp: new Date().getTime()
- },
- list: {
- ticketFor: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- createdAt: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- ticketChannel: entry(c.id, renderChannel(c)),
- },
- hidden: {
- guild: interaction.guild.id
- }
- }
- log(data, interaction.client);
- } catch (e) { console.log(e)}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Create Ticket")
- .setDescription(`Ticket created. You can view it here: <#${c.id}>`)
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ], components: []});
+ await create(interaction)
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 9015c13..b6e2aee 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,14 +1,195 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, MessageActionRow, MessageButton } 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 generateKeyValueList from "../../utils/generateKeyValueList.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("about")
.setDescription("Shows info about a user")
+ .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [user/about]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { renderUser, renderDelta } = interaction.client.logger
+ let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+ let flags: string[] = [];
+ if ([
+ "438733159748599813", // Pinea
+ "317731855317336067", // Mini
+ "261900651230003201", // Coded
+ "511655498676699136", // Zan
+ ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER") }
+ if ((await interaction.client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER") }
+ member.user.flags.toArray().map(flag => {
+ flags.push(flag.toString())
+ })
+ if (member.user.bot === true) { flags.push("BOT") }
+ // Check if they are boosting the server
+ if (member.premiumSince) { flags.push("BOOSTER") }
+ let nameReplacements = {
+ "NUCLEUSDEVELOPER": "**Nucleus Developer**",
+ "CLICKSDEVELOPER": "Clicks Developer",
+ "HOUSE_BRAVERY": "Hypesquad Bravery",
+ "HOUSE_BRILLIANCE": "Hypesquad Brilliance",
+ "HOUSE_BALANCE": "Hypesquad Balance",
+ "HYPESQUAD_EVENTS": "Hypesquad Events",
+ "EARLY_SUPPORTER": "Early Supporter",
+ "BUGHUNTER_LEVEL_1": "Bug Hunter Level 1",
+ "BUGHUNTER_LEVEL_2": "Bug Hunter Level 2",
+ "PARTNERED_SERVER_OWNER": "Partnered Server Owner",
+ "DISCORD_EMPLOYEE": "Discord Staff",
+ "EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer",
+ "BOT": "Bot",
+ "BOOSTER": "Server Booster"
+ }
+ let members = await interaction.guild.members.fetch()
+ let membersArray = [...members.values()]
+ membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp)
+ let joinPos = membersArray.findIndex(m => m.id === member.user.id)
+
+ let roles = member.roles.cache.filter(r => r.id != interaction.guild.id).sort()
+ let s = "";
+ let count = 0;
+ let ended = false
+ roles.map(item => {
+ if (ended) return;
+ let string = `<@&${item.id}>, `
+ if(s.length + string.length > 1000) {
+ ended = true
+ s += `and ${roles.size - count} more`
+ return
+ };
+ count ++
+ s += string;
+ })
+ if(s.length > 0 && !ended) s = s.slice(0, -2);
+
+ let perms = ""
+ let permsArray = {
+ "ADMINISTRATOR": "Administrator",
+ "MANAGE_GUILD": "Manage Server",
+ "MANAGE_ROLES": "Manage Roles",
+ "MANAGE_CHANNELS": "Manage Channels",
+ "KICK_MEMBERS": "Kick Members",
+ "BAN_MEMBERS": "Ban Members",
+ "MODERATE_MEMBERS": "Moderate Members",
+ "MANAGE_NICKNAMES": "Manage Nicknames",
+ "MANAGE_WEBHOOKS": "Manage Webhooks",
+ "MANAGE_MESSAGES": "Manage Messages",
+ "VIEW_AUDIT_LOG": "View Audit Log",
+ "MENTION_EVERYONE": "Mention Everyone"
+ }
+ Object.keys(permsArray).map(perm => {
+ let hasPerm = member.permissions.has(perm as Discord.PermissionString)
+ perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`
+ })
+
+ let embeds = [
+ new generateEmojiEmbed()
+ .setTitle("User Info: General")
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ .setDescription(
+ flags.map(flag => {
+ if (nameReplacements[flag]) {
+ return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag];
+ }
+ }).join("\n") + "\n\n" +
+ generateKeyValueList({
+ "member": renderUser(member.user),
+ "nickname": member.nickname || "*None set*",
+ "id": `\`${member.id}\``,
+ "joined the server": renderDelta(member.joinedTimestamp),
+ "joined discord": renderDelta(member.user.createdTimestamp),
+ "boost status": member.premiumSince ? `Started boosting ${renderDelta(member.premiumSinceTimestamp)}` : "*Not boosting*",
+ "join position": `${joinPos + 1}`
+ })
+ )
+ .setThumbnail(await member.user.displayAvatarURL({dynamic: true}))
+ .setImage((await member.user.fetch()).bannerURL({format: "gif"})),
+ new generateEmojiEmbed()
+ .setTitle("User Info: Roles")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setDescription(
+ generateKeyValueList({
+ "member": renderUser(member.user),
+ "id": `\`${member.id}\``,
+ "roles": `${member.roles.cache.size - 1}`,
+ }) + "\n" +
+ (s.length > 0 ? s : "*None*")
+ )
+ .setThumbnail(await member.user.displayAvatarURL({dynamic: true})),
+ new generateEmojiEmbed()
+ .setTitle("User Info: Key Permissions")
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setDescription(
+ generateKeyValueList({
+ "member": renderUser(member.user),
+ "id": `\`${member.id}\``,
+ }) + "\n" + perms
+ )
+ .setThumbnail(await member.user.displayAvatarURL({dynamic: true}))
+ ]
+ let m
+ m = await interaction.reply({embeds: [new generateEmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true});
+ let page = 0
+ while (true) {
+ await interaction.editReply({
+ embeds: [embeds[page].setFooter({text: `Page ${page + 1} of ${embeds.length}`})],
+ components: [new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("left")
+ .setDisabled(page === 0),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setCustomId("right")
+ .setStyle("SECONDARY")
+ .setDisabled(page === embeds.length - 1),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("close")
+ .setStyle("DANGER")
+ ])]
+ })
+ let i
+ try {
+ i = await m.awaitMessageComponent({componentType: "BUTTON", time: 600000});
+ } catch { break }
+ i.deferUpdate()
+ if (i.component.customId == "left") {
+ if (page > 0) page--;
+ } else if (i.component.customId == "right") {
+ if (page < embeds.length - 1) page++;
+ } else if (i.component.customId == "close") {
+ break;
+ } else {
+ break;
+ }
+ }
+ await interaction.editReply({embeds: [m.embeds[0]], components: [new MessageActionRow().addComponents([
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY")
+ .setCustomId("left")
+ .setDisabled(true),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setCustomId("right")
+ .setStyle("SECONDARY")
+ .setDisabled(true),
+ new MessageButton()
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setCustomId("close")
+ .setStyle("PRIMARY")
+ .setDisabled(true)
+ ])]})
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index 9e22d0c..eb9042a 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -1,14 +1,32 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction } 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 generateKeyValueList from "../../utils/generateKeyValueList.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("avatar")
- .setDescription("Shows a users avatar")
+ .setDescription("Shows the avatar of a user")
+ .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [user/avatar]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { renderUser } = interaction.client.logger
+ let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+ await interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("User Info")
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ .setDescription(
+ generateKeyValueList({
+ "member": renderUser(member.user),
+ "url": member.user.displayAvatarURL({dynamic: true}),
+ })
+ )
+ .setImage(await member.user.displayAvatarURL({dynamic: true}))
+ ], ephemeral: true, fetchReply: true});
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index 489a109..c9abb77 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,144 +1,14 @@
-import Discord, { CommandInteraction, GuildMember } from "discord.js";
+import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
-import readConfig from "../utils/readConfig.js";
-import fetch from "node-fetch";
-import { TestString, NSFWCheck } from "../automations/unscan.js";
+import verify from "../automations/verify.js";
const command = new SlashCommandBuilder()
.setName("verify")
.setDescription("Get verified in the server")
const callback = async (interaction: CommandInteraction) => {
- // @ts-ignore
- let verify = interaction.client.verify
- await interaction.reply({embeds: [new generateEmojiEmbed()
- .setTitle("Loading")
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], ephemeral: true, fetchReply: true});
- let config = await readConfig(interaction.guild.id);
- if ((interaction.member as GuildMember).roles.cache.has(config.verify.role)) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`You already have the <@&${config.verify.role}> role`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- } else if (interaction.channel.id != config.verify.channel) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`You can only use this command in <#${config.verify.channel}>`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- }
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Checking our servers are up`)
- .setStatus("Warning")
- .setEmoji("NUCLEUS.LOADING")
- ]});
- try {
- let status = await fetch(`https://clicksminuteper.net`).then(res => res.status);
- if (status != 200) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Our servers appear to be down, please try again later`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- }
- } catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Our servers appear to be down, please try again later`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], components: [new Discord.MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setLabel("Open webpage")
- .setStyle("LINK")
- .setURL("https://clicksminuteper.net/"),
- new Discord.MessageButton()
- .setLabel("Support")
- .setStyle("LINK")
- .setURL("https://discord.gg/bPaNnxe")
- ])]});
- }
- if (config.filters.images.NSFW) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Checking your avatar is safe for work`)
- .setStatus("Warning")
- .setEmoji("NUCLEUS.LOADING")
- ]});
- if (await NSFWCheck((interaction.member as GuildMember).user.avatarURL({format: "png"}))) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- }
- }
- if (config.filters.wordFilter) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Checking your name is allowed`)
- .setStatus("Warning")
- .setEmoji("NUCLEUS.LOADING")
- ]});
- if (TestString((interaction.member as Discord.GuildMember).displayName, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict) != "none") {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake`)
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ]});
- }
- }
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`One moment...`)
- .setStatus("Warning")
- .setEmoji("NUCLEUS.LOADING")
- ]});
- let code = ""
- let length = 5
- let itt = 0
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- while (true) {
- itt += 1
- code = ""
- for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
- if (code in verify) continue;
- if (itt > 1000) {
- itt = 0
- length += 1
- continue
- }
- break;
- }
- verify[code] = {
- uID: interaction.member.user.id,
- gID: interaction.guild.id,
- rName: (await interaction.guild.roles.fetch(config.verify.role)).name,
- mCount: interaction.guild.memberCount,
- gName: interaction.guild.name,
- guildIcon: interaction.guild.iconURL({format: "png"})
- }
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Verify")
- .setDescription(`Looking good!\nClick the button below to get verified`)
- .setStatus("Success")
- .setEmoji("MEMBER.JOIN")
- ], components: [new Discord.MessageActionRow().addComponents([new Discord.MessageButton()
- .setLabel("Verify")
- .setStyle("LINK")
- .setURL(`https://clicksminuteper.net/nucleus/verify?code=${code}`)
- ])]});
+ verify(interaction);
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/config/emojis.json b/src/config/emojis.json
index b759b8a..4c60cab 100644
--- a/src/config/emojis.json
+++ b/src/config/emojis.json
@@ -35,6 +35,8 @@
"BLOCKCROSS": "952261738349330493",
"LEFT": "947441951148486728",
"RIGHT": "947441957473488916",
+ "UP": "963409197293273108",
+ "DOWN": "963409199549796352",
"DOWNLOAD": "947959513032585236",
"PILL": {
"TICK": "753314339082993832",
@@ -92,8 +94,7 @@
},
"KICK": "729263536785850458",
"BAN": "729263536643112991",
- "UNBAN": "729263536840114216",
- "NICKNAME": "729064531019694090"
+ "UNBAN": "729263536840114216"
},
"INVITE": {
"CREATE": "729064529274601482",
@@ -143,29 +144,28 @@
},
"SOFTBAN": "729764053941223476",
"VOICEMUTE": "729764054855450697",
- "CLEARHISTORY": "729764062270980096"
+ "CLEARHISTORY": "729764062270980096",
+ "NICKNAME": {
+ "RED": "959762533101731980",
+ "YELLOW": "729064531019694090",
+ "GREEN": "959762533072392202"
+ }
},
"BADGES": {
- "NUCLEUSDEVELOPER": "775783766147858534",
- "CLICKSDEVELOPER": "776140126156881950",
- "HYPESQUAD": {
- "BRILLIANCE": "775783766152577095",
- "BRAVERY": "775783765930016789",
- "BALANCE": "775783766303440937",
- "EVENTS": "775783766194126908"
- },
- "EARLYSUPPORTER": "775783766055452693",
- "BUGHUNTER": [
- null,
- "775783766252847154",
- "775783766130950234"
- ],
- "BOOSTER": "775783766131605545",
- "PARTNER": "775783766178005033",
- "STAFF": "775783766383788082",
- "VERIFIEDBOTDEVELOPER": "775783766425600060",
- "NITRO": "776149266775146546",
- "BOT": "776375959108190239"
+ "NUCLEUSDEVELOPER": "957722888360853595",
+ "CLICKSDEVELOPER": "957722888314683462",
+ "HOUSE_BRAVERY": "775783765930016789",
+ "HOUSE_BRILLIANCE": "775783766152577095",
+ "HOUSE_BALANCE": "775783766303440937",
+ "HYPESQUAD_EVENTS": "775783766194126908",
+ "EARLY_SUPPORTER": "775783766055452693",
+ "BUGHUNTER_LEVEL_1": "775783766252847154",
+ "BUGHUNTER_LEVEL_2": "775783766130950234",
+ "PARTNERED_SERVER_OWNER": "775783766178005033",
+ "DISCORD_EMPLOYEE": "775783766383788082",
+ "EARLY_VERIFIED_BOT_DEVELOPER": "775783766425600060",
+ "BOT": "776375959108190239",
+ "BOOSTER": "775783766131605545"
},
"VOICE": {
"CONNECT": "784785219391193138",
@@ -185,6 +185,9 @@
}
},
"GUILD": {
+ "RED": "959779988264079361",
+ "YELLOW": "729763053352124529",
+ "GREEN": "959779988503154698",
"EMOJI": {
"CREATE": "953035168115982437",
"EDIT": "729066518549233795",
@@ -193,7 +196,6 @@
"GRAPHS": "752214059159650396",
"SETTINGS": "752570111063228507",
"ICONCHANGE": "729763053612302356",
- "MODERATIONUPDATE": "729763053352124529",
"TICKET": {
"OPEN": "853245836331188264",
"CLOSE": "853580122506133505",
@@ -289,5 +291,56 @@
"ISSUE": "952295894412316672",
"SUGGESTION": "952295894399725588",
"OTHER": "952295894445883502"
+ },
+ "TRACKS": {
+ "ICON": "963170616444334171",
+ "HORIZONTAL": {
+ "LEFT": {
+ "ACTIVE": "963121920038035506",
+ "INACTIVE": "963121944239153242"
+ },
+ "MIDDLE": {
+ "ACTIVE": "963121925893263420",
+ "INACTIVE": "963121949796597870"
+ },
+ "RIGHT": {
+ "ACTIVE": "963121933384302602",
+ "INACTIVE": "963121956125831168"
+ }
+ },
+ "VERTICAL": {
+ "TOP": {
+ "ACTIVE": "963122664648630293",
+ "INACTIVE": "963122659862917140",
+ "GREY": {
+ "ACTIVE": "963123505052934144",
+ "INACTIVE": "963123495221469194"
+ }
+ },
+ "MIDDLE": {
+ "ACTIVE": "963122679332880384",
+ "INACTIVE": "963122673246937199",
+ "GREY": {
+ "ACTIVE": "963123517702955018",
+ "INACTIVE": "963123511927390329"
+ }
+ },
+ "BOTTOM": {
+ "ACTIVE": "963122691752218624",
+ "INACTIVE": "963122685691453552",
+ "GREY": {
+ "ACTIVE": "963123529988059187",
+ "INACTIVE": "963123523742748742"
+ }
+ }
+ },
+ "SINGLE": {
+ "ACTIVE": "963361162215424060",
+ "INACTIVE": "963361431758176316",
+ "GREY": {
+ "ACTIVE": "963361204695334943",
+ "INACTIVE": "963361200828198952"
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 49bd3c3..ac29238 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,3 +1,5 @@
+import getEmojiByName from "../utils/getEmojiByName.js";
+
export const event = 'channelDelete'
export async function callback(client, channel) {
@@ -35,6 +37,21 @@
displayName = "Channel"
}
}
+ let list = {
+ id: entry(channel.id, `\`${channel.id}\``),
+ name: entry(channel.id, `${channel.name}`),
+ topic: null,
+ type: entry(channel.type, readableType),
+ category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+ nsfw: null,
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor))
+ }
+ if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
+ else delete list.topic;
+ if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
+ else delete list.nsfw;
let data = {
meta:{
@@ -45,15 +62,7 @@
emoji: emoji,
timestamp: audit.createdTimestamp
},
- list: { // TODO: Add stuff like nsfw, theres loads missing here
- id: entry(channel.id, `\`${channel.id}\``),
- name: entry(channel.id, `${channel.name}`),
- type: entry(channel.type, readableType),
- category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor))
- },
+ list: list,
hidden: {
guild: channel.guild.id
}
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index f5d2f4d..f374edd 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -20,7 +20,7 @@
let changes = {
id: entry(nc.id, `\`${nc.id}\``),
channel: entry(nc.id, renderChannel(nc)),
- edited: entry(nc.createdTimestamp, renderDelta(nc.createdTimestamp)),
+ edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
}
if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
@@ -114,7 +114,7 @@
}
let t = oc.type.split("_")[1];
if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
-
+ if (!(Object.values(changes).length - 4)) return
let data = {
meta:{
type: 'channelUpdate',
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index b437b37..4935b4d 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,56 +1,10 @@
import { MessageActionRow, MessageButton } from "discord.js";
import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../utils/getEmojiByName";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import guide from "../automations/guide.js";
export const event = 'guildCreate';
-export const callback = async (client, guild) => {
- let pages = [
- new generateEmojiEmbed()
- .setTitle("Welcome to Nucleus")
- .setDescription(
- "Thanks for adding Nucleus to your server\n\n" +
- "On the next few pages you can find instructions on getting started, and commands you may want to set up\n\n" +
- "If you need support, have questions or want features, you can let us know in [Clicks](https://discord.gg/bPaNnxe)"
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger"),
- new generateEmojiEmbed()
- ]
- let m = await guild.systemChannel.send({embeds: [
- new generateEmojiEmbed()
- .setTitle("Welcome")
- .setDescription(`One moment...`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], fetchReply: true });
- let page = 0;
-
- let f = async () => {
-
- }
-
- while (true) {
- // edit interaction with pages[page]
- await m.edit({
- embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length}`})],
- components: [new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setDisabled(page === 0),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setDisabled(page === pages.length - 1)
- ])],
- fetchReply: true
- });
- // wait for interaction
- let interaction = await m.awaitMessageComponent({filter:f, componentType: "BUTTON", time: 60000});
- // change page variable accordingly
- if (interaction.component.customId == "left") {
- if (page > 0) page--;
- } else if (interaction.component.customId == "right") {
- if (page < pages.length - 1) page++;
- } else {
- await m.delete()
- break;
- }
- // break if required
- }
-}
\ No newline at end of file
+export async function callback(client, guild) {
+ guide(guild)
+}
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 46d7696..ea461ab 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,10 +1,12 @@
import humanizeDuration from 'humanize-duration';
+import { purgeByUser } from '../automations/tickets/delete.js';
import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
export const event = 'guildMemberRemove'
export async function callback(_, member) {
try { await statsChannelRemove(_, member); } catch {}
+ try { purgeByUser(member.id, member.guild); } catch {} // TODO: add this to ban as well
try {
const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
let data = {
diff --git a/src/events/messageChecks.ts b/src/events/messageChecks.ts
index 71ca965..83cfff1 100644
--- a/src/events/messageChecks.ts
+++ b/src/events/messageChecks.ts
@@ -1,4 +1,4 @@
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString } from '../automations/unscan.js'
+import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../automations/unscan.js'
import readConfig from '../utils/readConfig.js'
import { Message } from 'discord.js'
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 3b7c5c2..ccaacb8 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -16,7 +16,7 @@
timestamp: new Date().getTime()
},
separate: {
- start: `**Message:**\n\`\`\`${content}\`\`\``
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
},
list: {
id: entry(message.id, `\`${message.id}\``),
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index bb74f8d..318b0ef 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,11 +2,11 @@
export async function callback(client, oldMessage, newMessage) {
if (newMessage.author.id == client.user.id) return;
- if (!newMessage.content || !oldMessage.content) return;
const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
newMessage.reference = newMessage.reference || {}
- let newContent = newMessage.cleanContent
- let oldContent = oldMessage.cleanContent
+ let newContent = newMessage.cleanContent.replaceAll("`", "‘")
+ let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
+ if (newContent == oldContent) return;
if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
let data = {
@@ -19,7 +19,8 @@
timestamp: newMessage.editedTimestamp
},
separate: {
- start: `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n**After:**\n\`\`\`\n${newContent}\n\`\`\``,
+ start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
+ (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
end: `[[Jump to message]](${newMessage.url})`
},
list: {
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 487a45e..76af433 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -2,6 +2,7 @@
export async function callback(client, role) {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
+ if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
if (audit.executor.id == client.user.id) return;
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 0c6d03e..c5cbe63 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,7 +3,8 @@
export const event = 'roleDelete'
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
+ if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
if (audit.executor.id == client.user.id) return;
diff --git a/src/index.ts b/src/index.ts
index 9e2770c..3b735cb 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -11,5 +11,6 @@
client.logger = new Logger()
client.verify = {}
+client.roleMenu = {}
await client.login();
\ No newline at end of file
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 7deb5f5..fc8b76c 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -1,5 +1,5 @@
import Discord, { CommandInteraction, MessageActionRow, Message } from "discord.js";
-import EmojiEmbed from "./generateEmojiEmbed.js"
+import generateEmojiEmbed from "./generateEmojiEmbed.js"
import getEmojiByName from "./getEmojiByName.js";
class confirmationMessage {
@@ -8,6 +8,12 @@
emoji: string;
description: string;
color: string;
+ customCallback: () => any;
+ customButtonTitle: string;
+ customButtonDisabled: boolean;
+ customCallbackString: string = "";
+ customCallbackClicked: boolean = false;
+ customCallbackResponse: any = null;
constructor(interaction: CommandInteraction) {
this.interaction = interaction;
@@ -16,54 +22,81 @@
this.emoji = "";
this.description = "";
this.color = "";
+ this.customCallback = () => {}
}
setTitle(title: string) { this.title = title; return this }
setEmoji(emoji: string) { this.emoji = emoji; return this }
setDescription(description: string) { this.description = description; return this }
setColor(color: string) { this.color = color; return this }
+ addCustomCallback(title: string, disabled: boolean, callback: () => any, callbackClicked: string) {
+ this.customButtonTitle = title;
+ this.customButtonDisabled = disabled;
+ this.customCallback = callback;
+ this.customCallbackString = callbackClicked;
+ return this;
+ }
async send(editOnly?: boolean) {
- let object = {
- embeds: [
- new EmojiEmbed()
- .setEmoji(this.emoji)
- .setTitle(this.title)
- .setDescription(this.description)
- .setStatus(this.color)
- ],
- components: [
- new MessageActionRow().addComponents([
- new Discord.MessageButton()
- .setCustomId("yes")
- .setLabel("Yes")
- .setStyle("SUCCESS")
- .setEmoji(getEmojiByName("CONTROL.TICK", "id")),
- new Discord.MessageButton()
- .setCustomId("no")
- .setLabel("Cancel")
- .setStyle("DANGER")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])
- ],
- ephemeral: true,
- fetchReply: true
+ while (true) {
+ let object = {
+ embeds: [
+ new generateEmojiEmbed()
+ .setEmoji(this.emoji)
+ .setTitle(this.title)
+ .setDescription(this.description)
+ .setStatus(this.color)
+ .setFooter({text: this.customCallbackClicked ? this.customCallbackString : ""})
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setCustomId("yes")
+ .setLabel("Yes")
+ .setStyle("SUCCESS")
+ .setEmoji(getEmojiByName("CONTROL.TICK", "id")),
+ new Discord.MessageButton()
+ .setCustomId("no")
+ .setLabel("Cancel")
+ .setStyle("DANGER")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ].concat(this.customButtonTitle ? [new Discord.MessageButton()
+ .setCustomId("custom")
+ .setLabel(this.customButtonTitle)
+ .setStyle("SECONDARY")
+ .setDisabled(this.customButtonDisabled)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) // TODO: add an emoji
+ ] : []))
+ ],
+ ephemeral: true,
+ fetchReply: true
+ }
+ let m;
+ if ( editOnly ) {
+ m = await this.interaction.editReply(object);
+ } else {
+ m = await this.interaction.reply(object)
+ }
+ let component;
+ try {
+ component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 2.5 * 60 * 1000});
+ } catch (e) {
+ return {success: false, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse}; // TODO: Check the type of the error; change the error message here
+ }
+ if (component.customId === "yes") {
+ component.deferUpdate();
+ return {success: true, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse};
+ } else if (component.customId === "no") {
+ component.deferUpdate();
+ return {success: false, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse};
+ } else if (component.customId === "custom") {
+ component.deferUpdate();
+ this.customCallbackResponse = this.customCallback();
+ this.customCallbackClicked = true;
+ this.customButtonDisabled = true;
+ editOnly = true;
+ }
}
- let m;
- if ( editOnly ) {
- m = await this.interaction.editReply(object);
- } else {
- m = await this.interaction.reply(object)
- }
- let component;
- try {
- component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 2.5 * 60 * 1000});
- } catch (e) {
- return false; // TODO: Check the type of the error; change the error message here
- }
- component.deferUpdate();
-
- return component.customId === "yes"
}
}
diff --git a/src/utils/generateKeyValueList.ts b/src/utils/generateKeyValueList.ts
index b3e276f..c9eb0c8 100644
--- a/src/utils/generateKeyValueList.ts
+++ b/src/utils/generateKeyValueList.ts
@@ -5,7 +5,14 @@
export function capitalize(s: string) {
s = s.replace(/([A-Z])/g, ' $1');
- return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
+ return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0]
+ .toUpperCase() + s.slice(1)
+ .toLowerCase()
+ .replace("discord", "Discord");
+}
+
+export function toCapitals(s: string) {
+ return s[0].toUpperCase() + s.slice(1).toLowerCase();
}
function keyValueList(data) {
diff --git a/src/utils/getEmojiByName.ts b/src/utils/getEmojiByName.ts
index bbc8f24..80410df 100644
--- a/src/utils/getEmojiByName.ts
+++ b/src/utils/getEmojiByName.ts
@@ -11,11 +11,11 @@
return id.toString();
}
if (id === undefined) {
- return `<a:a:946346549271732234>`
+ return `<a:_:946346549271732234>`
} else if (id.toString().startsWith("a")) {
- return `<a:a:${id.toString().slice(1, id.toString().length)}>`
+ return `<a:_:${id.toString().slice(1, id.toString().length)}>`
}
- return `<:a:${id}>`;
+ return `<:_:${id}>`;
}
export default getEmojiByName;
diff --git a/src/utils/log.ts b/src/utils/log.ts
index d807831..14e9750 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -10,7 +10,8 @@
export class Logger {
- renderUser(user: Discord.User) {
+ renderUser(user: Discord.User | string) {
+ if (typeof user == 'string') return `${user} [<@${user}>]`;
return `${user.username} [<@${user.id}>]`;
}
renderTime(t: number) {
@@ -45,7 +46,6 @@
}
-
async getAuditLog(guild: Discord.Guild, event) {
await wait(250)
let auditLog = await guild.fetchAuditLogs({type: event});
diff --git a/src/utils/readConfig.ts b/src/utils/readConfig.ts
index c53d2cc..fb6835b 100644
--- a/src/utils/readConfig.ts
+++ b/src/utils/readConfig.ts
@@ -1,85 +1,165 @@
export default async function readConfig(guild: string): Promise<any> {
- let config = {
- filters: {
- images: {
- NSFW: true,
- size: true
- },
- malware: true,
- wordFilter: {
- enabled: true,
- words: {
- strict: [],
- loose: []
- },
- allowed: {
- users: [],
- roles: [],
- channels: []
- }
- },
- invite: {
- enabled: false,
- allowed: {
- users: [],
- channels: [],
- roles: []
- }
- },
- pings: {
- mass: 5,
- everyone: true,
- roles: true,
- allowed: {
- roles: [],
- rolesToMention: [],
- users: [],
- channels: []
- }
- }
- },
- welcome: {
- enabled: true,
- verificationRequired: {
- message: false,
- role: false
- },
- welcomeRole: null,
- channel: '895209752315961344', // null, channel ID or 'dm'
- message: "Welcome to the server, {@}!"
- },
- stats: [
- {
- enabled: true,
- channel: '951910554291818526',
- text: "{count} members | {count:bots} bots | {count:humans} humans"
- }
- ],
- logging: {
- logs: {
- enabled: true,
- channel: '952247098437427260',
- toLog: "3fffff" // "3ffffe" = - channelUpdate, "3fffff" = all
- },
- staff: {}
- },
- verify: {
- enabled: true,
- channel: '895210691479355392',
- role: '934941369137524816',
- },
- tickets: {
- enabled: true,
- category: "952302254302584932",
- types: "3f",
- customTypes: null,
- supportRole: null,
- maxTickets: 5
- }
- };
-
- return config
-
-}
\ No newline at end of file
+ let config = {
+ singleEventNotifications: {
+ statsChannelDeleted: false
+ },
+ filters: {
+ images: {
+ NSFW: true,
+ size: true
+ },
+ malware: true,
+ wordFilter: {
+ enabled: true,
+ words: {
+ strict: [],
+ loose: []
+ },
+ allowed: {
+ users: [],
+ roles: [],
+ channels: []
+ }
+ },
+ invite: {
+ enabled: false,
+ allowed: {
+ users: [],
+ channels: [],
+ roles: []
+ }
+ },
+ pings: {
+ mass: 5,
+ everyone: true,
+ roles: true,
+ allowed: {
+ roles: [],
+ rolesToMention: [],
+ users: [],
+ channels: []
+ }
+ }
+ },
+ welcome: {
+ enabled: true,
+ verificationRequired: {
+ message: false,
+ role: false
+ },
+ welcomeRole: null,
+ channel: '895209752315961344', // null, channel ID or 'dm'
+ message: "Welcome to the server, {@}!"
+ },
+ stats: [
+ {
+ enabled: true,
+ channel: '951910554291818526',
+ text: "{count} members | {count:bots} bots | {count:humans} humans"
+ }
+ ],
+ logging: {
+ logs: {
+ enabled: true,
+ channel: '952247098437427260',
+ toLog: "3fffff" // "3ffffe" = - channelUpdate, "3fffff" = all
+ },
+ staff: {
+ channel: "895212366252367933"
+ }
+ },
+ verify: {
+ enabled: true,
+ role: '934941369137524816',
+ },
+ tickets: {
+ enabled: true,
+ category: "952302254302584932",
+ types: "3f",
+ customTypes: null,
+ supportRole: null,
+ maxTickets: 5
+ },
+ moderation: {
+ mute: {
+ timeout: true,
+ role: null, // TODO: actually give it
+ text: null,
+ link: null
+ },
+ kick: {
+ text: "Appeal here",
+ link: "https://clicksminuteper.net"
+ },
+ ban: {
+ text: null,
+ link: null
+ },
+ softban: {
+ text: null,
+ link: null
+ },
+ warn: {
+ text: null,
+ link: null
+ },
+ role: {
+ role: "934941369137524816"
+ },
+ },
+ tracks: [
+ {
+ name: "Moderation",
+ retainPrevious: false,
+ nullable: true,
+ track: [
+ "934941369137524816",
+ "934941399806246984",
+ "934941408849186856",
+ "934941466734764092"
+ ],
+ manageableBy: []
+ },
+ {
+ name: "Verification",
+ retainPrevious: false,
+ nullable: true,
+ track: [
+ "963166531318067250"
+ ],
+ manageableBy: []
+ }
+ ],
+ roleMenu: {
+ enabled: true,
+ allowWebUI: true,
+ options: [
+ {
+ name: "Gender",
+ description: "What's your gender?",
+ min: 1,
+ max: 1,
+ options: [
+ { name: "Male", role: "959901318019948574" },
+ { name: "Female", role: "959901346000154674" },
+ { name: "Non Binary", description: "Better than the others", role: "959901378363420704"}
+ ]
+ },
+ {
+ name: "Pick",
+ min: 0,
+ max: 4,
+ options: [
+ { name: "Test Role 1", role: "934941369137524816" },
+ { name: "Test Role 2", role: "934941399806246984" },
+ { name: "Test Role 3", role: "934941408849186856" },
+ { name: "Test Role 4", role: "934941466734764092" }
+ ]
+ }
+ ]
+ }
+ };
+ return config;
+}