huge changes once again
diff --git a/src/commands/categorisationTest.ts b/src/commands/categorisationTest.ts
index 4a28841..a6c7479 100644
--- a/src/commands/categorisationTest.ts
+++ b/src/commands/categorisationTest.ts
@@ -1,21 +1,22 @@
import { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
-import { SelectMenuComponent, SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
+import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import generateKeyValueList, { toCapitals } from "../utils/generateKeyValueList.js";
import getEmojiByName from "../utils/getEmojiByName.js";
+import client from "../utils/client.js"
const command = new SlashCommandBuilder()
.setName("categorise")
.setDescription("Categorises your servers channels")
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderChannel } = client.logger
let channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
let categorised = {}
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading...")
.setEmoji("NUCLEUS.LOADING")
.setStatus("Success")
@@ -40,7 +41,7 @@
}
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Categorise")
.setDescription(generateKeyValueList({
channel: renderChannel(c),
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 8b17db3..4581c0f 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import addPlurals from "../../utils/plurals.js";
import client from "../../utils/client.js";
@@ -18,13 +18,14 @@
)
.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) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
@@ -35,11 +36,11 @@
if (confirmation.success) {
let dmd = false
let dm;
- let config = await client.database.read(interaction.guild.id);
+ let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle("Banned")
.setDescription(`You have been banned in ${interaction.guild.name}` +
@@ -57,13 +58,13 @@
} catch {}
try {
let member = (interaction.options.getMember("user") as GuildMember)
- let reason = interaction.options.getString("reason") ?? "No reason provided"
+ let reason = interaction.options.getString("reason")
member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
- reason: reason
+ reason: reason ?? "No reason provided"
})
- // @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderDelta } = interaction.user.client.logger
+ try { await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason) } catch {}
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
let data = {
meta: {
type: 'memberBan',
@@ -86,9 +87,9 @@
guild: interaction.guild.id
}
}
- log(data, member.user.client);
+ log(data);
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle(`Ban`)
.setDescription("Something went wrong and the user was not banned")
@@ -98,14 +99,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Ban`)
.setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.GREEN")
.setTitle(`Ban`)
.setDescription("No changes were made")
@@ -125,13 +126,13 @@
// Check if Nucleus can ban the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to ban
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
+ if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
// Do not allow banning Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot ban myself"
// Allow the owner to ban anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the `ban_members` permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow ban
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
new file mode 100644
index 0000000..c3a4388
--- /dev/null
+++ b/src/commands/mod/info.ts
@@ -0,0 +1,285 @@
+import { HistorySchema } from '../../utils/database';
+import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
+import { SlashCommandSubcommandBuilder, SelectMenuOption } from "@discordjs/builders";
+import { WrappedCheck } from "jshaiku";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import getEmojiByName from "../../utils/getEmojiByName.js";
+import client from "../../utils/client.js";
+import { modalInteractionCollector } from '../../utils/dualCollector.js';
+import pageIndicator from '../../utils/createPageIndicator.js';
+
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder
+ .setName("info")
+ .setDescription("Shows moderator information about a user")
+ .addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true))
+
+
+const types = {
+ "warn": {emoji: "PUNISH.WARN.YELLOW", text: "Warned"},
+ "mute": {emoji: "PUNISH.MUTE.YELLOW", text: "Muted"},
+ "join": {emoji: "MEMBER.JOIN", text: "Joined"},
+ "leave": {emoji: "MEMBER.LEAVE", text: "Left"},
+ "kick": {emoji: "MEMBER.KICK", text: "Kicked"},
+ "softban": {emoji: "PUNISH.SOFTBAN", text: "Softbanned"},
+ "ban": {emoji: "MEMBER.BAN", text: "Banned"},
+ "unban": {emoji: "MEMBER.UNBAN", text: "Unbanned"},
+ "purge": {emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared"},
+ "nickname": {emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed"}
+}
+
+function historyToString(history: HistorySchema) {
+ let s = `${getEmojiByName(types[history.type].emoji)} ${
+ history.amount ? (history.amount + " ") : ""
+ }${
+ types[history.type].text
+ } on <t:${Math.round(history.occurredAt.getTime() / 1000)}:F>`;
+ if (history.moderator) { s += ` by <@${history.moderator}>`; }
+ if (history.reason) { s += `\n**Reason:**\n> ${history.reason}`; }
+ if (history.before) { s += `\n**Before:**\n> ${history.before}`; }
+ if (history.after) { s += `\n**After:**\n> ${history.after}`; }
+ return s + "\n";
+}
+
+
+class TimelineSection {
+ name: string;
+ content: {data: HistorySchema, rendered: string}[] = []
+
+ addContent = (content: {data: HistorySchema, rendered: string}) => { this.content.push(content); return this; }
+ contentLength = () => { return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0); };
+ generateName = () => {
+ let first = Math.round(this.content[0].data.occurredAt.getTime() / 1000)
+ let last = Math.round(this.content[this.content.length - 1].data.occurredAt.getTime() / 1000)
+ if (first === last) { return this.name = `<t:${first}:F>`; }
+ return this.name = `<t:${first}:F> - <t:${last}:F>`;
+ }
+}
+
+const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+
+async function showHistory(member, interaction: CommandInteraction) {
+ let currentYear = new Date().getFullYear();
+ let pageIndex = null;
+ let m, history, current;
+ let refresh = true;
+ let filteredTypes = [];
+ let openFilterPane = false;
+ while (true) {
+ if (refresh) {
+ history = await client.database.history.read(member.guild.id, member.id, currentYear);
+ history = history.sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime()).reverse();
+ if (openFilterPane) {
+ let tempFilteredTypes = filteredTypes
+ if (filteredTypes.length === 0) { tempFilteredTypes = Object.keys(types); }
+ history = history.filter(h => tempFilteredTypes.includes(h.type))
+ };
+ refresh = false;
+ }
+ let groups: TimelineSection[] = []
+ if (history.length > 0) {
+ current = new TimelineSection()
+ history.forEach(event => {
+ if (current.contentLength() + historyToString(event).length > 2000 || current.content.length === 5) {
+ groups.push(current);
+ current.generateName();
+ current = new TimelineSection();
+ }
+ current.addContent({data: event, rendered: historyToString(event)});
+ });
+ current.generateName();
+ groups.push(current);
+ if (pageIndex === null) { pageIndex = groups.length - 1; }
+ }
+ let components = (
+ openFilterPane ? [
+ new MessageActionRow().addComponents([new Discord.MessageSelectMenu().setOptions(
+ Object.entries(types).map(([key, value]) => ({
+ label: value.text,
+ value: key,
+ default: filteredTypes.includes(key),
+ emoji: client.emojis.resolve(getEmojiByName(value.emoji, "id"))
+ }))
+ ).setMinValues(1).setMaxValues(Object.keys(types).length).setCustomId("filter").setPlaceholder("Select at least one event")])
+ ] : []).concat([
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("prevYear")
+ .setLabel((currentYear - 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("prevPage")
+ .setLabel("Previous page")
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setCustomId("today")
+ .setLabel("Today")
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setCustomId("nextPage")
+ .setLabel("Next page")
+ .setStyle("PRIMARY")
+ .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ new MessageButton()
+ .setCustomId("nextYear")
+ .setLabel((currentYear + 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(currentYear === new Date().getFullYear()),
+ ]), new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Mod notes")
+ .setCustomId("modNotes")
+ .setStyle("PRIMARY")
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new MessageButton()
+ .setLabel("Filter")
+ .setCustomId("openFilter")
+ .setStyle(openFilterPane ? "SUCCESS" : "PRIMARY")
+ .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
+ ])
+ ])
+ let end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
+ Math.max(groups.length, 1),
+ groups.length === 0 ? 1 : pageIndex
+ ) + (currentYear == new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
+ ) + " " + currentYear.toString()
+ if (groups.length > 0) {
+ let toRender = groups[Math.min(pageIndex, groups.length - 1)]
+ m = await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Moderation history for " + member.user.username)
+ .setDescription(`**${toRender.name}**\n\n` + toRender.content.map(c => c.rendered).join("\n") + end)
+ .setStatus("Success")
+ .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
+ ], components: components});
+ } else {
+ m = await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Moderation history for " + member.user.username)
+ .setDescription(`**${currentYear}**\n\n*No events*` + `\n\n` + end)
+ .setStatus("Success")
+ .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
+ ], components: components});
+ }
+ let i;
+ try {
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Moderation history for " + member.user.username)
+ .setDescription(m.embeds[0].description)
+ .setStatus("Danger")
+ .setFooter({text: "Message timed out"})
+ ]});
+ return 0
+ }
+ i.deferUpdate()
+ if (i.customId === "filter") {
+ filteredTypes = i.values;
+ pageIndex = null;
+ refresh = true;
+ }
+ if (i.customId === "prevYear") { currentYear--; pageIndex = null; refresh = true; }
+ if (i.customId === "nextYear") { currentYear++; pageIndex = null; refresh = true; }
+ if (i.customId === "prevPage") {
+ pageIndex--;
+ if (pageIndex < 0) { pageIndex = null; currentYear--; refresh = true; }
+ }
+ if (i.customId === "nextPage") {
+ pageIndex++;
+ if (pageIndex >= groups.length) { pageIndex = 0; currentYear++; refresh = true; }
+ }
+ if (i.customId === "today") { currentYear = new Date().getFullYear(); pageIndex = null; refresh = true; }
+ if (i.customId === "modNotes") { return 1 }
+ if (i.customId === "openFilter") { openFilterPane = !openFilterPane; refresh = true }
+ }
+}
+
+
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ let m;
+ let member = (interaction.options.getMember("user")) as Discord.GuildMember;
+ await interaction.reply({embeds: [new EmojiEmbed()
+ .setEmoji("NUCLEUS.LOADING")
+ .setTitle("Downloading data...")
+ .setStatus("Success")
+ ], ephemeral: true, fetchReply: true});
+ let note;
+ let firstLoad = true;
+ while (true) {
+ note = await client.database.notes.read(member.guild.id, member.id);
+ if (firstLoad && !note) { await showHistory(member, interaction); }
+ firstLoad = false;
+ m = await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Mod notes for " + member.user.username)
+ .setDescription(note ? note : "*No note set*")
+ .setStatus("Success")
+ ], components: [new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(`${note ? "Modify" : "Create"} note`)
+ .setStyle("PRIMARY")
+ .setCustomId("modify")
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new MessageButton()
+ .setLabel("View moderation history")
+ .setStyle("PRIMARY")
+ .setCustomId("history")
+ .setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
+ ])]});
+ let i;
+ try {
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) { return }
+ if (i.customId === "modify") {
+ await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Editing moderator note`).addComponents(
+ // @ts-ignore
+ new MessageActionRow().addComponents(new TextInputComponent()
+ .setCustomId("note")
+ .setLabel("Note")
+ .setMaxLength(4000)
+ .setRequired(false)
+ .setStyle("PARAGRAPH")
+ .setValue(note ? note : "")
+ )
+ ))
+ await interaction.editReply({
+ embeds: [new EmojiEmbed()
+ .setTitle("Mod notes for " + member.user.username)
+ .setDescription("Modal opened. If you can't see it, click back and try again.")
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ], components: [new MessageActionRow().addComponents([new MessageButton()
+ .setLabel("Back")
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("back")
+ ])]
+ });
+ let out;
+ try {
+ out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "modify")
+ } catch (e) { continue }
+ if (out.fields) {
+ let toAdd = out.fields.getTextInputValue("note") || null;
+ await client.database.notes.create(member.guild.id, member.id, toAdd);
+ } else { continue }
+ } else if (i.customId === "history") {
+ i.deferUpdate();
+ if (!await showHistory(member, interaction) ) return
+ }
+ }
+}
+
+const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let member = (interaction.member as GuildMember)
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
+ return true
+}
+
+export { command };
+export { callback };
+export { check };
\ No newline at end of file
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 20fbc01..97ead7b 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -3,7 +3,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
@@ -17,13 +17,14 @@
.addChoices([["Yes", "yes"], ["No", "no"]])
)
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kick")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
@@ -33,11 +34,11 @@
if (confirmation.success) {
let dmd = false
let dm;
- let config = await client.database.read(interaction.guild.id);
+ let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kicked")
.setDescription(`You have been kicked in ${interaction.guild.name}` +
@@ -57,8 +58,9 @@
(interaction.options.getMember("user") as GuildMember).kick(interaction.options.getString("reason") ?? "No reason provided.")
let member = (interaction.options.getMember("user") as GuildMember)
let reason = interaction.options.getString("reason") ?? null
+ try { await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason) } catch {}
// @ts-ignore
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
+ const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
let data = {
meta: {
type: 'memberKick',
@@ -83,9 +85,9 @@
guild: member.guild.id
}
}
- log(data, member.client);
+ log(data);
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
.setTitle(`Kick`)
.setDescription("Something went wrong and the user was not kicked")
@@ -95,14 +97,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Kick`)
.setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.KICK.GREEN")
.setTitle(`Kick`)
.setDescription("No changes were made")
@@ -122,13 +124,13 @@
// Check if Nucleus can kick the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to kick
- if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the `kick_members` permission";
+ if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the Kick members permission";
// Do not allow kicking Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot kick myself"
// Allow the owner to kick anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has kick_members permission
- if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the `kick_members` permission";
+ if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the Kick members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow kick
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 79beeb3..5f42b27 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
@@ -31,14 +31,14 @@
minutes: interaction.options.getInteger("minutes") || 0,
seconds: interaction.options.getInteger("seconds") || 0
}
- let config = await client.database.read(interaction.guild.id)
+ let config = await client.database.guilds.read(interaction.guild.id)
let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "")
if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`
let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds
if (muteTime == 0) {
let m = await interaction.reply({embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Mute")
.setDescription("How long should the user be muted")
@@ -93,7 +93,7 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
} catch { return }
component.deferUpdate();
- if (component.customId == "cancel") return interaction.editReply({embeds: [new generateEmojiEmbed()
+ if (component.customId == "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
.setDescription("Mute cancelled")
@@ -111,7 +111,7 @@
}
} else {
await interaction.reply({embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Mute")
.setDescription("Loading...")
@@ -123,7 +123,7 @@
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Mute")
.setDescription(keyValueList({
- "user": `<@!${user.id}> (${user.user.username})`,
+ "user": renderUser(user),
"time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
"reason": `\n> ${reason ? reason : "*No reason provided*"}`
})
@@ -135,11 +135,11 @@
if (confirmation.success) {
let dmd = false
let dm;
- let config = await client.database.read(interaction.guild.id);
+ let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Muted")
.setDescription(`You have been muted in ${interaction.guild.name}` +
@@ -156,15 +156,16 @@
dmd = true
}
} catch {}
+ let member = (interaction.options.getMember("user") as GuildMember)
try {
if (config.moderation.mute.timeout) {
- (interaction.options.getMember("user") as GuildMember).timeout(muteTime * 1000, interaction.options.getString("reason") || "No reason provided")
+ member.timeout(muteTime * 1000, interaction.options.getString("reason") || "No reason provided")
}
if (config.moderation.mute.role) {
- (interaction.options.getMember("user") as GuildMember).roles.add(config.moderation.mute.role)
+ member.roles.add(config.moderation.mute.role)
}
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle(`Mute`)
.setDescription("Something went wrong and the user was not mute")
@@ -173,8 +174,9 @@
if (dmd) await dm.delete()
return
}
+ try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Mute`)
.setDescription("The member was muted" + (failed ? ", but could not be notified" : ""))
@@ -190,7 +192,7 @@
timestamp: new Date().getTime()
},
list: {
- user: entry((interaction.options.getMember("user") as GuildMember).user.id, renderUser((interaction.options.getMember("user") as GuildMember).user)),
+ user: entry(member.user.id, renderUser(member.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")
@@ -199,9 +201,9 @@
guild: interaction.guild.id
}
}
- log(data, client);
+ log(data);
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle(`Mute`)
.setDescription("No changes were made")
@@ -221,7 +223,7 @@
// Check if Nucleus can mute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to mute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
+ if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the Moderate members permission";
// Do not allow the user to have admin or be the owner
if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
@@ -229,7 +231,7 @@
// Allow the owner to mute anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the `moderate_members` permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow mute
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index c09e197..e154277 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -2,9 +2,10 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
+import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -16,13 +17,14 @@
.addChoices([["Yes", "yes"], ["No", "no"]])
)
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"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`
@@ -39,7 +41,7 @@
try {
if (interaction.options.getString("notify") == "yes") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
@@ -56,6 +58,9 @@
let before = member.nickname
let nickname = interaction.options.getString("name")
member.setNickname(nickname ?? null, "Nucleus Nickname command")
+ try { await client.database.history.create(
+ "nickname", interaction.guild.id, member.user, interaction.user,
+ null, before, nickname) } catch {}
// @ts-ignore
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger
let data = {
@@ -78,9 +83,9 @@
guild: interaction.guild.id
}
}
- log(data, client);
+ log(data);
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle(`Nickname`)
.setDescription("Something went wrong and the users nickname could not be changed.")
@@ -90,14 +95,14 @@
return
}
let failed = (dmd == false && interaction.options.getString("notify") == "yes")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Nickname`)
.setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.GREEN")
.setTitle(`Nickname`)
.setDescription("No changes were made")
@@ -117,11 +122,11 @@
// 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 (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the `manage_nicknames` permission";
+ if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the Manage nicknames permission";
// Allow the owner to change anyone's nickname
if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_nicknames permission
- if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the `manage_nicknames` permission";
+ if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the Manage nicknames permission";
// Allow changing your own nickname
if (member == apply) return true
// Check if the user is below on the role list
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index c6a44b3..9aab260 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 generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -25,7 +26,7 @@
if (!(["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(channel.type.toString()))) {
return await interaction.reply({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("You cannot purge this channel")
@@ -39,7 +40,7 @@
if ( !interaction.options.getInteger("amount") ) {
await interaction.reply({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("Select how many messages to delete")
@@ -53,7 +54,7 @@
while (true) {
let m = await interaction.editReply({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("Select how many messages to delete. You can continue clicking until all messages are cleared.")
@@ -118,7 +119,7 @@
}
if (deleted.length === 0) return await interaction.editReply({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription("No messages were deleted")
@@ -126,10 +127,13 @@
],
components: []
})
+ if (user) {
+ try { await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, deleted.length) } catch {}
+ }
let attachmentObject;
try {
// @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderChannel } = interaction.user.client.logger
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
let data = {
meta: {
type: 'channelPurge',
@@ -149,7 +153,7 @@
guild: interaction.guild.id
}
}
- log(data, interaction.user.client);
+ log(data);
let out = ""
deleted.reverse().forEach(message => {
out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
@@ -163,7 +167,7 @@
description: "Purge log"
}
} catch {}
- let m = await interaction.editReply({embeds: [new generateEmojiEmbed()
+ let m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`CHANNEL.PURGE.GREEN`)
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -180,14 +184,14 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
} catch {}
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new generateEmojiEmbed()
+ interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Uploaded")
.setStatus("Success")
], components: [], files: [attachmentObject]})
} else {
- interaction.editReply({embeds: [new generateEmojiEmbed()
+ interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -218,17 +222,20 @@
messages = await (channel as TextChannel).bulkDelete(toDelete, true);
}
} catch(e) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.RED")
.setTitle(`Purge`)
.setDescription("Something went wrong and no messages were deleted")
.setStatus("Danger")
], components: []})
}
+ if (user) {
+ try { await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, messages.size) } catch {}
+ }
let attachmentObject;
try {
// @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderChannel } = interaction.user.client.logger
+ const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
let data = {
meta: {
type: 'channelPurge',
@@ -248,7 +255,7 @@
guild: interaction.guild.id
}
}
- log(data, interaction.user.client);
+ log(data);
let out = ""
messages.reverse().forEach(message => {
out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
@@ -262,7 +269,7 @@
description: `Purge log`
}
} catch {}
- let m = await interaction.editReply({embeds: [new generateEmojiEmbed()
+ let m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`CHANNEL.PURGE.GREEN`)
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -279,14 +286,14 @@
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
} catch {}
if (component && component.customId === "download") {
- interaction.editReply({embeds: [new generateEmojiEmbed()
+ interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Transcript uploaded above")
.setStatus("Success")
], components: [], files: [attachmentObject]})
} else {
- interaction.editReply({embeds: [new generateEmojiEmbed()
+ interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("Messages cleared")
@@ -294,7 +301,7 @@
], components: []})
}
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.PURGE.GREEN")
.setTitle(`Purge`)
.setDescription("No changes were made")
@@ -310,9 +317,9 @@
// Allow the owner to purge
if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_messages permission
- if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the `manage_messages` permission";
+ if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the Manage messages permission";
// Check if nucleus has the manage_messages permission
- if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the `manage_messages` permission";
+ if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the Manage messages permission";
// Allow warn
return true
}
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 2498746..d9a8421 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -4,7 +4,8 @@
import { WrappedCheck } from "jshaiku";
import keyValueList from "../../utils/generateKeyValueList.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -18,11 +19,11 @@
["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
]))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
let time = parseInt(interaction.options.getString("time") ?? "0");
if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10 }
let confirmation = await new confirmationMessage(interaction)
- .setEmoji("CHANNEL.SLOWMODE.RED")
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
.setTitle("Slowmode")
.setDescription(keyValueList({
"time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay",
@@ -34,22 +35,22 @@
try {
(interaction.channel as TextChannel).setRateLimitPerUser(time)
} catch (e) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.RED")
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.OFF")
.setTitle(`Slowmode`)
.setDescription("Something went wrong while setting the slowmode")
.setStatus("Danger")
], components: []})
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji(`CHANNEL.SLOWMODE.GREEN`)
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji(`CHANNEL.SLOWMODE.ON`)
.setTitle(`Slowmode`)
.setDescription("The channel slowmode was set successfully")
.setStatus("Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.GREEN")
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("CHANNEL.SLOWMODE.ON")
.setTitle(`Slowmode`)
.setDescription("No changes were made")
.setStatus("Success")
@@ -60,9 +61,9 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
// Check if Nucleus can set the slowmode
- if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the `manage_channels` permission";
+ if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the Manage channels permission";
// Check if the user has manage_channel permission
- if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the `manage_channels` permission";
+ if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the Manage channels permission";
// Allow slowmode
return true
}
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 5a01287..ea4a447 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
import addPlural from "../../utils/plurals.js";
@@ -18,13 +18,14 @@
)
.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) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
@@ -34,11 +35,11 @@
.send()
if (confirmation.success) {
let dmd = false;
- let config = await client.database.read(interaction.guild.id);
+ let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softbanned")
.setDescription(`You have been softbanned from ${interaction.guild.name}` +
@@ -54,29 +55,31 @@
dmd = true
}
} catch {}
+ let member = (interaction.options.getMember("user") as GuildMember)
try {
- await (interaction.options.getMember("user") as GuildMember).ban({
+ await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
reason: interaction.options.getString("reason")
});
- await interaction.guild.members.unban(interaction.options.getMember("user") as GuildMember, "Softban");
+ await interaction.guild.members.unban(member, "Softban");
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle(`Softban`)
.setDescription("Something went wrong and the user was not softbanned")
.setStatus("Danger")
], components: []})
}
+ try { await client.database.history.create("softban", interaction.guild.id, member.user, interaction.options.getString("reason")) } catch {}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Softban`)
.setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.GREEN")
.setTitle(`Softban`)
.setDescription("No changes were made")
@@ -96,13 +99,13 @@
// Check if Nucleus can ban the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
+ if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
// Do not allow softbanning Nucleus
if (member.id == me.id) throw "I cannot softban myself"
// Allow the owner to ban anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the `ban_members` permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow softban
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index f7bf74f..7f605d9 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -1,9 +1,10 @@
import { CommandInteraction, GuildMember, User } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -11,14 +12,14 @@
.setDescription("Unbans a user")
.addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
let bans = await interaction.guild.bans.fetch()
let user = interaction.options.getString("user")
let resolved = bans.find(ban => ban.user.id == user)
if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() == user.toLowerCase())
if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() == user.toLowerCase())
if (!resolved) {
- return interaction.reply({embeds: [new generateEmojiEmbed()
+ return interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Unban")
.setDescription(`Could not find any user called \`${user}\``)
.setEmoji("PUNISH.UNBAN.RED")
@@ -39,8 +40,9 @@
try {
await interaction.guild.members.unban(resolved.user as User, "Unban");
let member = (resolved.user as User)
+ try { await client.database.history.create("unban", interaction.guild.id, member, interaction.user) } catch {}
// @ts-ignore
- const { log, NucleusColors, entry, renderUser, renderDelta } = interaction.user.client.logger
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
let data = {
meta: {
type: 'memberUnban',
@@ -61,23 +63,23 @@
guild: interaction.guild.id
}
}
- log(data, member.client);
+ log(data);
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.UNBAN.RED")
.setTitle(`Unban`)
.setDescription("Something went wrong and the user was not unbanned")
.setStatus("Danger")
], components: []})
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.UNBAN.GREEN`)
.setTitle(`Unban`)
.setDescription("The member was unbanned")
.setStatus("Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.UNBAN.GREEN")
.setTitle(`Unban`)
.setDescription("No changes were made")
@@ -90,11 +92,11 @@
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can unban members
- if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
+ if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
// Allow the owner to unban anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the `ban_members` permission";
+ if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
// Allow unban
return true
}
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 2a98c54..5a1b67c 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -2,8 +2,9 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -15,13 +16,14 @@
.addChoices([["Yes", "yes"], ["No", "no"]])
)
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Unmute")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "yes" ? '' : ' not'}** be notified\n\n`
@@ -34,7 +36,7 @@
try {
if (interaction.options.getString("notify") != "no") {
dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle("Unmuted")
.setDescription(`You have been unmuted in ${interaction.guild.name}` +
@@ -48,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 generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
.setTitle(`Unmute`)
.setDescription("Something went wrong and the user was not unmuted")
@@ -57,15 +59,16 @@
if (dmd) await dm.delete()
return
}
+ try { await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, interaction.options.getString("reason")) } catch {}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Unmute`)
.setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.MUTE.GREEN")
.setTitle(`Unmute`)
.setDescription("No changes were made")
@@ -85,13 +88,13 @@
// Check if Nucleus can unmute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to unmute
- if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
+ if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the Moderate members permission";
// Do not allow the user to have admin or be the owner
if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
// Allow the owner to unmute anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the `moderate_members` permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow unmute
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index 705c04a..b3875a7 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,8 +1,9 @@
-import Discord, { CategoryChannel, CommandInteraction } from "discord.js";
+import Discord, { CategoryChannel, CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { WrappedCheck } from "jshaiku";
import getEmojiByName from "../../utils/getEmojiByName.js";
+import pageIndicator from "../../utils/createPageIndicator.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -10,8 +11,9 @@
.setDescription("View the server as a specific member")
.addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true))
-const callback = async (interaction: CommandInteraction) => {
- let channels = []
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ let channels = [];
+ let m;
interaction.guild.channels.cache.forEach(channel => {
if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel)
})
@@ -22,39 +24,83 @@
)
let autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"]
channels = channels.map(c => c.sort((a, b) => {
- if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.name.localeCompare(b.name)
- if (autoSortBelow.includes(a.type)) return -1
- if (autoSortBelow.includes(b.type)) return 1
+ if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position
+ if (autoSortBelow.includes(a.type)) return 1
+ if (autoSortBelow.includes(b.type)) return -1
return a.position - b.position
}))
+ // Sort all arrays by the position of the first channels parent position
+ channels = channels.sort((a, b) => {
+ if (!a[0].parent) return -1
+ if (!b[0].parent) return 1
+ return a[0].parent.position - b[0].parent.position
+ })
let member = interaction.options.getMember("member") as Discord.GuildMember
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ m = await interaction.reply({embeds: [new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
.setTitle("Viewing as " + member.displayName)
.setStatus("Success")
- ], ephemeral: true})
+ ], ephemeral: true, fetchReply: true})
let page = 0;
while (true) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
.setTitle("Viewing as " + member.displayName)
.setStatus("Success")
.setDescription(
- `${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}` +
- "Visible:\n" +
+ `**${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}**` + "\n" +
channels[page].map(c => {
- console.log(c)
- return (channels[page] as Discord.GuildChannel).permissionsFor(member).has("VIEW_CHANNEL") ?
- `${getEmojiByName("ICONS.CHANNEL." + c.type)} ${c.name}\n` : ""
- }).join("")
+ let channelType = c.type
+ if (interaction.guild.rulesChannelId == c.id) channelType = "RULES"
+ else if ("nsfw" in c && c.nsfw) channelType += "_NSFW"
+ return c.permissionsFor(member).has("VIEW_CHANNEL") ? (
+ `${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` + (() => {
+ if ("threads" in c && c.threads.cache.size > 0) {
+ return c.threads.cache.map(t => ` ${
+ getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") + " " +
+ getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")} ${t.name}`).join("\n") + "\n"
+ }return ""
+ })()) : ""
+ }).join("") + "\n" + pageIndicator(channels.length, page)
)
+ ], components: [
+ new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(channels.map((c, index) => ({
+ label: c[0].parent ? c[0].parent.name : "Uncategorised",
+ value: index.toString(),
+ default: page === index
+ }))).setCustomId("select").setMaxValues(1).setMinValues(1).setPlaceholder("Select a category")]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel(page === 0 ? "" : (channels[page - 1][0].parent ? channels[page - 1][0].parent.name : "Uncategorised"))
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("previous"),
+ new MessageButton()
+ .setLabel(page === channels.length - 1 ? "" : (channels[page + 1][0].parent ? channels[page + 1][0].parent.name : "Uncategorised"))
+ .setDisabled(page === channels.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle("PRIMARY")
+ .setCustomId("next")
+ ])
]})
- break
+ let i;
+ try {
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) { return }
+ i.deferUpdate()
+ if (i.customId === "next") { page++; }
+ else if (i.customId === "previous") { page--; }
+ else if (i.customId === "select") { page = parseInt(i.values[0]); }
}
}
+
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
+ return true // FIXME FOR RELEASE
+ let member = (interaction.member as GuildMember)
+ if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ return true
}
export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index b8fb98f..370f347 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -2,9 +2,10 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
+import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -23,7 +24,7 @@
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
@@ -39,7 +40,7 @@
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warned")
.setDescription(`You have been warned in ${interaction.guild.name}` +
@@ -51,7 +52,7 @@
dmd = true
}
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle(`Warn`)
.setDescription("Something went wrong and the user was not warned")
@@ -76,10 +77,15 @@
guild: interaction.guild.id
}
}
- log(data, client);
+ try { await client.database.history.create(
+ "warn", interaction.guild.id,
+ (interaction.options.getMember("user") as GuildMember).user,
+ interaction.user, interaction.options.getString("reason")
+ )} catch {}
+ log(data);
let failed = (dmd == false && interaction.options.getString("notify") != "no")
if (!failed) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
@@ -87,7 +93,7 @@
], components: []})
} else {
let m = await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription("The user's DMs are not open\n\nWhat would you like to do?")
@@ -110,7 +116,7 @@
try {
component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
} catch (e) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("No changes were made")
@@ -119,7 +125,7 @@
}
if ( component.customId == "here" ) {
await interaction.channel.send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription(`You have been warned` +
@@ -129,14 +135,14 @@
content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
})
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus("Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
.setDescription("The warn was logged")
@@ -145,7 +151,7 @@
}
}
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle(`Warn`)
.setDescription("No changes were made")
@@ -167,7 +173,7 @@
// Allow the owner to warn anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the `moderate_members` permission";
+ if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the Moderate members permission";
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow warn
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index 814d2f5..eb94de4 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import guide from "../../automations/guide.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index 8b25820..7f7d4b8 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -1,7 +1,7 @@
import { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -10,7 +10,7 @@
.setDescription("Invites Nucleus to your server")
const callback = (interaction: CommandInteraction) => {
- interaction.reply({embeds: [new generateEmojiEmbed()
+ interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Invite")
.setDescription("You can invite Nucleus to your server by clicking the button below")
.setEmoji("NUCLEUS.LOGO")
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 58413c6..f10dcae 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,6 +1,6 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js"
@@ -9,18 +9,18 @@
.setName("ping")
.setDescription("Gets the bot's ping time")
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
// WEBSOCKET | Nucleus -> Discord
// EDITING | Nucleus -> discord -> nucleus | edit time / 2
let initial = new Date().getTime();
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Ping")
.setDescription(`Checking ping times...`)
.setEmoji("NUCLEUS.LOADING")
.setStatus("Danger")
], ephemeral: true});
let ping = new Date().getTime() - initial;
- interaction.editReply({embeds: [new generateEmojiEmbed()
+ interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Ping")
.setDescription(
`**Ping:** \`${ping}ms\`\n` +
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index 1a0602e..cb10e7a 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -1,7 +1,7 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -11,7 +11,7 @@
const callback = (interaction: CommandInteraction) => {
interaction.reply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Stats")
.setDescription(
`**Servers:** ${client.guilds.cache.size}\n` +
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index c07d9b8..4e3a1c8 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -11,7 +11,7 @@
.setDescription("Sends a suggestion to the developers")
.addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
// @ts-ignore
const { renderUser } = client.logger
let suggestion = interaction.options.getString("suggestion");
@@ -26,21 +26,21 @@
if (confirmation.success) {
await (client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setTitle(`Suggestion`)
.setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
.setStatus("Danger")
.setEmoji("NUCLEUS.LOGO")
]
})
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("ICONS.ADD")
.setTitle(`Suggest`)
.setDescription("Your suggestion was sent successfully")
.setStatus("Success")
], components: []})
} else {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("ICONS.OPP.ADD")
.setTitle(`Suggest`)
.setDescription("No changes were made")
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 3174421..cc6c554 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -8,7 +8,7 @@
.setDescription("we changed the fucking charger again!")
.addStringOption(option => option.setName("link").setDescription("fuck you").setRequired(false))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
console.log(await testLink(interaction.options.getString("link")))
}
diff --git a/src/commands/role/all.ts b/src/commands/role/all.ts
index 44e77fd..d24110b 100644
--- a/src/commands/role/all.ts
+++ b/src/commands/role/all.ts
@@ -1,17 +1,161 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import getEmojiByName from "../../utils/getEmojiByName.js";
+import addPlural from "../../utils/plurals.js";
+import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("all")
.setDescription("Gives or removes a role from everyone")
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("This command is not yet finished [role/all]");
+class Filter {
+ name: string;
+ data: object;
+ checkFunction: (member) => boolean;
+ inverted: boolean = false;
+ constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
+ if (typeof name === "function") { this.name = name(data);
+ } else { this.name = name; }
+ this.data = data;
+ this.checkFunction = check;
+ }
+ flip() { this.inverted = true; return this; }
+ check(member) {
+ if (this.inverted) return !this.checkFunction(member)
+ else return this.checkFunction(member)
+ }
}
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const filterList = {
+ member: {
+ render: "Member",
+ has: {
+ render: "has",
+ role: (role) => ( new Filter((data) => `Member has role <@&${data.role}>`, {role: role, type: Discord.Role, render: "role"}, (member) => { return member.roles.cache.has(role)}))
+ },
+ joined: {
+ render: "joined",
+ before: (date) => ( new Filter((data) => `Joined server before <t:${Math.round(date.getTime() / 1000)}:F>`, {date: date, type: Date, render: "before"}, (member) => {
+ return member.joinedTimestamp < date.getTime()
+ })),
+ after: (date) => ( new Filter((data) => `Joined server after <t:${Math.round(date.getTime() / 1000)}:F>`, {date: date, type: Date, render: "after"}, (member) => {
+ return member.joinedTimestamp > date.getTime()
+ }).flip())
+ },
+ nickname: {
+ render: "Nickname",
+ set: () => ( new Filter((data) => `Member has a nickname set"`, {render: "set"}, (member) => { return member.nickname !== null})),
+ include: (name) => ( new Filter((data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
+ return member.displayName.includes(name)})),
+ startsWith: (name) => ( new Filter((data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
+ return member.displayName.startsWith(name)})),
+ endsWith: (name) => ( new Filter((data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
+ return member.displayName.endsWith(name)}))
+ }
+ },
+ account: {
+ render: "Account",
+ created: {
+ render: "created",
+ before: (date) => ( new Filter((data) => `Account created before <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "before"}, (member) => {
+ return member.user.createdTimestamp < date.getTime()
+ })),
+ after: (date) => ( new Filter((data) => `Account created after <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "after"}, (member) => {
+ return member.user.createdTimestamp < date.getTime()
+ }).flip())
+ },
+ is: {
+ render: "is",
+ human: () => ( new Filter((data) => `Member is a human`, {human: true, render: "human"}, (member) => { return !member.bot })),
+ },
+ username: {
+ render: "Username",
+ include: (name) => ( new Filter((data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
+ return member.user.name.includes(name)})),
+ startsWith: (name) => ( new Filter((data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
+ return member.user.name.startsWith(name)})),
+ endsWith: (name) => ( new Filter((data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
+ return member.user.name.endsWith(name)}))
+ }
+ }
+}
+
+const callback = async (interaction: CommandInteraction) => {
+ await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Role all")
+ .setDescription("Loading...")
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOADING")
+ ], ephemeral: true, fetchReply: true})
+ let filters: Filter[] = [
+ filterList.member.has.role("959901346000154674"),
+ filterList.member.nickname.startsWith("Pinea"),
+ filterList.member.joined.before(new Date(2022, 1)).flip()
+ ]
+ let all = true;
+ while (true) {
+ let count = 0;
+ let affected = []
+ let members = interaction.guild.members.cache
+ if (all) {
+ members.forEach(member => {
+ let applies = true;
+ filters.forEach(filter => { if (!filter.check(member)) { applies = false } })
+ if (applies) { affected.push(member) }
+ })
+ } else {
+ members.forEach(member => {
+ let applies = false;
+ filters.forEach(filter => { if (filter.check(member)) { applies = true } })
+ if (applies) { affected.push(member) }
+ })
+ }
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Role all")
+ .setDescription((all ? "All of the following must be true:" : "Any of the following must be true") + "\n" +
+ filters.map((f) => {
+ count ++;
+ return (count == 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
+ (f.inverted ? "**not** " : "") + `${f.name}`
+ }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length.toString(), "member")}`)
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setStatus("Success")
+ ], components: [
+ new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(filters.map((f, index) => ({
+ label: (f.inverted ? "(Not) " : "") + f.name,
+ value: index.toString()
+ }))).setMinValues(1).setMaxValues(filters.length).setCustomId("select").setPlaceholder("Remove a filter")]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Apply")
+ .setStyle("PRIMARY")
+ .setCustomId("apply")
+ .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
+ .setDisabled(affected.length === 0),
+ new MessageButton()
+ .setLabel("Add filter")
+ .setStyle("PRIMARY")
+ .setCustomId("add")
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
+ .setDisabled(filters.length >= 25)
+ ])
+ ]})
+ break
+ }
+}
+
+const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let member = (interaction.member as GuildMember)
+ let me = (interaction.guild.me as GuildMember)
+ if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the Manage roles permission";
+ // Allow the owner to role anyone
+ if (member.id == interaction.guild.ownerId) return true
+ // Check if the user has manage_roles permission
+ if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ // Allow role
return true;
}
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index b45e1d1..bb79098 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -1,17 +1,84 @@
-import { CommandInteraction } from "discord.js";
+import { CommandInteraction, GuildMember, Role } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import client from "../../utils/client.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import keyValueList from "../../utils/generateKeyValueList.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("user")
.setDescription("Gives or removes a role from someone")
+ .addUserOption(option => option.setName("user").setDescription("The member to give or remove the role from").setRequired(true))
+ .addRoleOption(option => option.setName("role").setDescription("The role to give or remove").setRequired(true))
+ .addStringOption(option => option.setName("action").setDescription("The action to perform").setRequired(true).addChoices([
+ ["Add", "give"],
+ ["Remove", "remove"]
+ ]))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("This command is not yet finished [role/user]");
+
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser, renderRole } = client.logger
+ let action = interaction.options.getString("action");
+ // TODO:[Modals] Replace this with a modal
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("GUILD.ROLES.DELETE")
+ .setTitle("Role")
+ .setDescription(keyValueList({
+ "user": renderUser(interaction.options.getUser("user")),
+ "role": renderRole(interaction.options.getRole("role"))
+ })
+ + `\nAre you sure you want to ${action == "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
+ .setColor("Danger")
+ .send()
+ if (confirmation.success) {
+ try {
+ let member = interaction.options.getMember("user") as GuildMember
+ let role = interaction.options.getRole("role") as Role
+ if (interaction.options.getString("action") == "give") {
+ member.roles.add(role)
+ } else {
+ member.roles.remove(role)
+ }
+ } catch (e) {
+ return await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription("Something went wrong and the role could not be added")
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ], components: []})
+ }
+ return await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Role")
+ .setDescription(`The role has been ${action == "give" ? "given" : "removed"} successfully`)
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ], components: []})
+ } else {
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setTitle("Role")
+ .setDescription(`You have cancelled the role change.`)
+ .setStatus("Danger")
+ ], components: []})
+ }
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let member = (interaction.member as GuildMember)
+ let me = (interaction.guild.me as GuildMember)
+ let apply = (interaction.options.getMember("user") as GuildMember)
+ if (member == null || me == null || apply == null) throw "That member is not in the server"
+ // Check if Nucleus has permission to role
+ if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the Manage roles permission";
+ // Allow the owner to role anyone
+ if (member.id == interaction.guild.ownerId) return true
+ // Check if the user has manage_roles permission
+ if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+ // Check if the role is above or equal to the user's highest role
+ if (apply.roles.highest.comparePositionTo(member.roles.highest) >= 0) throw "You cannot give a role higher than your highest role";
+ // Allow role
return true;
}
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 895d2cc..28e09aa 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction, Guild, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js"
@@ -10,10 +10,10 @@
.setName("about")
.setDescription("Shows info about the server")
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
let guild = interaction.guild as Guild;
const { renderUser, renderDelta } = client.logger
- interaction.reply({embeds: [new generateEmojiEmbed()
+ interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Server Info")
.setStatus("Success")
.setEmoji("GUILD.GREEN")
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 448f26a..19a389b 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,6 +1,6 @@
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import generateEmojiEmbed from "../../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -17,7 +17,7 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
- m = await interaction.reply({embeds: [new generateEmojiEmbed()
+ m = await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading")
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
@@ -27,7 +27,7 @@
try {
channel = interaction.options.getChannel("channel")
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Log Channel")
.setDescription("The channel you provided is not a valid channel")
@@ -36,7 +36,7 @@
}
channel = channel as Discord.TextChannel
if (channel.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
.setDescription(`You must choose a channel in this server`)
.setStatus("Danger")
@@ -52,10 +52,10 @@
.send(true)
if (confirmation.success) {
try {
- await client.database.write(interaction.guild.id, {"logging.logs.channel": channel.id})
+ await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id})
} catch (e) {
console.log(e)
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
.setDescription(`Something went wrong and the log channel could not be set`)
.setStatus("Danger")
@@ -63,7 +63,7 @@
], components: []});
}
} else {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log Channel")
.setDescription(`No changes were made`)
.setStatus("Success")
@@ -72,10 +72,10 @@
}
}
let clicks = 0;
- let data = await client.database.read(interaction.guild.id);
+ let data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.logs.channel;
while (true) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log channel")
.setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
.setStatus("Success")
@@ -96,14 +96,14 @@
clicks += 1;
if (clicks == 2) {
clicks = 0;
- await client.database.write(interaction.guild.id, {}, ["logging.logs.channel"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["logging.logs.channel"])
channel = undefined;
}
} else {
break
}
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Log channel")
.setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
.setStatus("Success")
diff --git a/src/commands/settings/logs/ignore.ts b/src/commands/settings/logs/ignore.ts
index 4b66307..12af085 100644
--- a/src/commands/settings/logs/ignore.ts
+++ b/src/commands/settings/logs/ignore.ts
@@ -1,7 +1,7 @@
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import generateEmojiEmbed from "../../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from '../../../utils/confirmationMessage.js';
import keyValueList from '../../../utils/generateKeyValueList.js';
@@ -24,7 +24,7 @@
let channel = interaction.options.getChannel("addchannel")
let user = interaction.options.getUser("adduser")
let role = interaction.options.getRole("addrole")
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading")
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
@@ -34,7 +34,7 @@
try {
channel = interaction.guild.channels.cache.get(channel.id)
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Logs > Ignore")
.setDescription("The channel you provided is not a valid channel")
@@ -43,7 +43,7 @@
}
channel = channel as Discord.TextChannel
if (channel.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Logs > Ignore")
.setDescription(`You must choose a channel in this server`)
.setStatus("Danger")
@@ -55,7 +55,7 @@
try {
user = interaction.guild.members.cache.get(user.id).user
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("USER.DELETE")
.setTitle("Logs > Ignore")
.setDescription("The user you provided is not a valid user")
@@ -68,7 +68,7 @@
try {
role = interaction.guild.roles.cache.get(role.id)
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("ROLE.DELETE")
.setTitle("Logs > Ignore")
.setDescription("The role you provided is not a valid role")
@@ -77,7 +77,7 @@
}
role = role as Discord.Role
if (role.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Logs > Ignore")
.setDescription(`You must choose a role in this server`)
.setStatus("Danger")
@@ -97,12 +97,12 @@
.setColor("Warning")
.send(true)
if (confirmation.success) {
- let data = client.database.read(interaction.guild.id)
+ let data = client.database.guilds.read(interaction.guild.id)
if (channel) data.logging.logs.ignore.channels.concat([channel.id])
if (user) data.logging.logs.ignore.users.concat([user.id])
if (role) data.logging.logs.ignore.roles.concat([role.id])
if (interaction.options.getString("action") == "add") {
- await client.database.append(interaction.guild.id, data)
+ await client.database.guilds.append(interaction.guild.id, data)
}
}
}
diff --git a/src/commands/settings/staff/channel.ts b/src/commands/settings/staff/channel.ts
index 354d7f1..74605cf 100644
--- a/src/commands/settings/staff/channel.ts
+++ b/src/commands/settings/staff/channel.ts
@@ -1,6 +1,6 @@
import { ChannelType } from 'discord-api-types';
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import generateEmojiEmbed from "../../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -17,7 +17,7 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
- m = await interaction.reply({embeds: [new generateEmojiEmbed()
+ m = await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading")
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
@@ -27,7 +27,7 @@
try {
channel = interaction.options.getChannel("channel")
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Staff Notifications Channel")
.setDescription("The channel you provided is not a valid channel")
@@ -36,7 +36,7 @@
}
channel = channel as Discord.TextChannel
if (channel.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
.setDescription(`You must choose a channel in this server`)
.setStatus("Danger")
@@ -55,9 +55,9 @@
.send(true)
if (confirmation.success) {
try {
- await client.database.write(interaction.guild.id, {"logging.staff.channel": channel.id})
+ await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id})
} catch (e) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
.setDescription(`Something went wrong and the staff notifications channel could not be set`)
.setStatus("Danger")
@@ -65,7 +65,7 @@
], components: []});
}
} else {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications Channel")
.setDescription(`No changes were made`)
.setStatus("Success")
@@ -74,10 +74,10 @@
}
}
let clicks = 0;
- let data = await client.database.read(interaction.guild.id);
+ let data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications channel")
.setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
.setStatus("Success")
@@ -98,14 +98,14 @@
clicks += 1;
if (clicks == 2) {
clicks = 0;
- await client.database.write(interaction.guild.id, {}, ["logging.staff.channel"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["logging.staff.channel"])
channel = undefined;
}
} else {
break
}
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Staff Notifications channel")
.setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
.setStatus("Success")
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 670a2f2..b505c5c 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,5 +1,5 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -22,7 +22,7 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
m = await interaction.reply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Loading")
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
@@ -42,7 +42,7 @@
channel = interaction.guild.channels.cache.get(options.category.id)
} catch {
return await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Tickets > Category")
.setDescription("The channel you provided is not a valid category")
@@ -52,7 +52,7 @@
}
channel = channel as Discord.CategoryChannel
if (channel.guild.id != interaction.guild.id) return interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Category")
.setDescription(`You must choose a category in this server`)
.setStatus("Danger")
@@ -62,7 +62,7 @@
}
if (options.maxtickets) {
if (options.maxtickets < 1) return interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Max Tickets")
.setDescription(`You must choose a number greater than 0`)
.setStatus("Danger")
@@ -76,7 +76,7 @@
role = interaction.guild.roles.cache.get(options.supportping.id)
} catch {
return await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLE.DELETE")
.setTitle("Tickets > Support Ping")
.setDescription("The role you provided is not a valid role")
@@ -86,7 +86,7 @@
}
role = role as Discord.Role
if (role.guild.id != interaction.guild.id) return interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Support Ping")
.setDescription(`You must choose a role in this server`)
.setStatus("Danger")
@@ -116,10 +116,10 @@
if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets
if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id
try {
- await client.database.write(interaction.guild.id, toUpdate)
+ await client.database.guilds.write(interaction.guild.id, toUpdate)
} catch (e) {
return interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets")
.setDescription(`Something went wrong and the staff notifications channel could not be set`)
.setStatus("Danger")
@@ -129,7 +129,7 @@
}
} else {
return interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets")
.setDescription(`No changes were made`)
.setStatus("Success")
@@ -138,7 +138,7 @@
});
}
}
- let data = await client.database.read(interaction.guild.id);
+ let data = await client.database.guilds.read(interaction.guild.id);
data.tickets.customTypes = data.tickets.customTypes.filter((v, i, a) => a.indexOf(v) === i)
let lastClicked = "";
let embed;
@@ -152,7 +152,7 @@
customTypes: data.tickets.customTypes
}
while (true) {
- embed = new generateEmojiEmbed()
+ embed = new EmojiEmbed()
.setTitle("Tickets")
.setDescription(
`${data.enabled ? "" : getEmojiByName("TICKETS.REPORT")} **Enabled:** ${data.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`}\n` +
@@ -206,23 +206,23 @@
if (i.component.customId == "clearCategory") {
if (lastClicked == "cat") {
lastClicked = "";
- await client.database.write(interaction.guild.id, {}, ["tickets.category"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["tickets.category"])
data.category = undefined;
} else lastClicked = "cat";
} else if (i.component.customId == "clearMaxTickets") {
if (lastClicked == "max") {
lastClicked = "";
- await client.database.write(interaction.guild.id, {}, ["tickets.maxTickets"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["tickets.maxTickets"])
data.maxTickets = 5;
} else lastClicked = "max";
} else if (i.component.customId == "clearSupportPing") {
if (lastClicked == "sup") {
lastClicked = "";
- await client.database.write(interaction.guild.id, {}, ["tickets.supportRole"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["tickets.supportRole"])
data.supportRole = undefined;
} else lastClicked = "sup";
} else if (i.component.customId == "enabled") {
- await client.database.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
data.enabled = !data.enabled;
} else if (i.component.customId == "manageTypes") {
data = await manageTypes(interaction, data, m);
@@ -238,7 +238,7 @@
if (data.useCustom) {
let customTypes = data.customTypes;
await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
.setDescription(
"**Custom types enabled**\n\n" +
@@ -299,7 +299,7 @@
.setPlaceholder("Select types to use")
])
await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
.setDescription(
"**Default types enabled**\n\n" +
@@ -331,7 +331,7 @@
if (i.component.customId == "types") {
i.deferUpdate()
let types = toHexInteger(i.values, ticketTypes);
- await client.database.write(interaction.guild.id, { "tickets.types": types })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
data.types = types;
} else if (i.component.customId == "removeTypes") {
i.deferUpdate()
@@ -340,7 +340,7 @@
if (customTypes) {
customTypes = customTypes.filter((t) => !types.includes(t));
customTypes = customTypes.length > 0 ? customTypes : null;
- await client.database.write(interaction.guild.id, { "tickets.customTypes": customTypes })
+ await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
data.customTypes = customTypes;
}
} else if (i.component.customId == "addType") {
@@ -357,7 +357,7 @@
)
))
await interaction.editReply({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setTitle("Tickets > Types")
.setDescription("Modal opened. If you can't see it, click back and try again.")
.setStatus("Success")
@@ -369,15 +369,16 @@
.setCustomId("back")
])]
});
- let out
+ let out;
try {
out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "addType")
} catch (e) { continue }
if (out.fields) {
let toAdd = out.fields.getTextInputValue("type");
if (!toAdd) { continue }
+ toAdd = toAdd.substring(0, 80)
try {
- await client.database.append(interaction.guild.id, "tickets.customTypes", toAdd)
+ await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd)
} catch { continue }
data.customTypes = data.customTypes || [];
if (!data.customTypes.includes(toAdd)) {
@@ -386,11 +387,11 @@
} else { continue }
} else if (i.component.customId == "switchToDefault") {
i.deferUpdate()
- await client.database.write(interaction.guild.id, { "tickets.useCustom": false }, [])
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
data.useCustom = false;
} else if (i.component.customId == "switchToCustom") {
i.deferUpdate()
- await client.database.write(interaction.guild.id, { "tickets.useCustom": true }, [])
+ await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
data.useCustom = true;
} else {
i.deferUpdate()
diff --git a/src/commands/settings/verify/role.ts b/src/commands/settings/verify/role.ts
index 68b4bf9..44406e9 100644
--- a/src/commands/settings/verify/role.ts
+++ b/src/commands/settings/verify/role.ts
@@ -1,5 +1,5 @@
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import generateEmojiEmbed from "../../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -14,7 +14,7 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let m;
- m = await interaction.reply({embeds: [new generateEmojiEmbed()
+ m = await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Loading")
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
@@ -24,7 +24,7 @@
try {
role = interaction.options.getRole("role")
} catch {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("GUILD.ROLES.DELETE")
.setTitle("Verify Role")
.setDescription("The role you provided is not a valid role")
@@ -33,7 +33,7 @@
}
role = role as Discord.Role
if (role.guild.id != interaction.guild.id) {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(`You must choose a role in this server`)
.setStatus("Danger")
@@ -49,10 +49,10 @@
.send(true)
if (confirmation.success) {
try {
- await client.database.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
+ await client.database.guilds.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
} catch (e) {
console.log(e)
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(`Something went wrong while setting the verify role`)
.setStatus("Danger")
@@ -60,7 +60,7 @@
], components: []});
}
} else {
- return interaction.editReply({embeds: [new generateEmojiEmbed()
+ return interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(`No changes were made`)
.setStatus("Success")
@@ -69,10 +69,10 @@
}
}
let clicks = 0;
- let data = await client.database.read(interaction.guild.id);
+ let data = await client.database.guilds.read(interaction.guild.id);
let role = data.verify.role;
while (true) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(role ? `Your verify role is currently set to <@&${role}>` : `You have not set a verify role`)
.setStatus("Success")
@@ -93,14 +93,14 @@
clicks += 1;
if (clicks == 2) {
clicks = 0;
- await client.database.write(interaction.guild.id, {}, ["verify.role", "verify.enabled"])
+ await client.database.guilds.write(interaction.guild.id, {}, ["verify.role", "verify.enabled"])
role = undefined;
}
} else {
break
}
}
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify Role")
.setDescription(role ? `Your verify role is currently set to <@&${role}}>` : `You have not set a verify role`)
.setStatus("Success")
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 80bcbad..a9f0075 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -9,7 +9,6 @@
.setDescription("Get and manage the servers tags")
const callback = (interaction: CommandInteraction) => {
- // try { statsChannelAdd(interaction.client, interaction.member); } catch {} // TODO: REMOVE THIS FOR PRODUCTION
interaction.reply("This command is not yet finished [tag]");
}
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index e53f94f..c1ed839 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
@@ -16,26 +16,26 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let name = interaction.options.getString("name");
let value = interaction.options.getString("value");
- if (name.length > 100) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (name.length > 100) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("Tag names cannot be longer than 100 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- if (value.length > 1000) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (value.length > 1000) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("Tag values cannot be longer than 1000 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- let data = await client.database.read(interaction.guild.id);
- if (data.tags.length >= 100) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ let data = await client.database.guilds.read(interaction.guild.id);
+ if (data.tags.length >= 100) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("You cannot have more than 100 tags")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- if (data.tags[name]) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("That tag already exists")
.setStatus("Danger")
@@ -52,23 +52,23 @@
.setColor("Warning")
.setInverted(true)
.send()
- if (!confirmation) return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("No changes were made")
.setStatus("Success")
.setEmoji("PUNISH.NICKNAME.GREEN")
]});
try {
- await client.database.write(interaction.guild.id, {[`tags.${name}`]: value});
+ await client.database.guilds.write(interaction.guild.id, {[`tags.${name}`]: value});
} catch (e) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("Something went wrong and the tag was not created")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], components: []});
}
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Create")
.setDescription("Tag created")
.setStatus("Success")
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index ff54ee5..f24a5fc 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
@@ -14,8 +14,8 @@
const callback = async (interaction: CommandInteraction): Promise<any> => {
let name = interaction.options.getString("name");
- let data = await client.database.read(interaction.guild.id);
- if (!data.tags[name]) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ let data = await client.database.guilds.read(interaction.guild.id);
+ if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tags")
.setDescription("That tag does not exist")
.setStatus("Danger")
@@ -32,25 +32,25 @@
.setColor("Warning")
.setInverted(true)
.send()
- if (!confirmation) return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Delete")
.setDescription("No changes were made")
.setStatus("Success")
.setEmoji("PUNISH.NICKNAME.GREEN")
]});
try {
- data = await client.database.read(interaction.guild.id);
+ data = await client.database.guilds.read(interaction.guild.id);
delete data.tags[name];
- await client.database.write(interaction.guild.id, {tags: data});
+ await client.database.guilds.write(interaction.guild.id, {tags: data});
} catch (e) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Delete")
.setDescription("Something went wrong and the tag was not deleted")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], components: []});
}
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Delete")
.setDescription("Tag deleted")
.setStatus("Success")
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 3cf73e5..b0a4835 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
@@ -18,32 +18,32 @@
let name = interaction.options.getString("name");
let value = interaction.options.getString("value") || "";
let newname = interaction.options.getString("newname") || "";
- if (!newname && !value) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (!newname && !value) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("You must specify a value or a new name")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- if (newname.length > 100) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (newname.length > 100) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("Tag names cannot be longer than 100 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- if (value.length > 2000) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (value.length > 2000) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("Tag values cannot be longer than 2000 characters")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- let data = await client.database.read(interaction.guild.id);
- if (!data.tags[name]) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ let data = await client.database.guilds.read(interaction.guild.id);
+ if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("That tag does not exist")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], ephemeral: true});
- if (newname && newname !== name && data.tags[newname]) return await interaction.reply({embeds: [new generateEmojiEmbed()
+ if (newname && newname !== name && data.tags[newname]) return await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("A tag with that name already exists")
.setStatus("Danger")
@@ -60,7 +60,7 @@
.setColor("Warning")
.setInverted(true)
.send()
- if (!confirmation) return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("No changes were made")
.setStatus("Success")
@@ -74,16 +74,16 @@
toUnset.push(`tags.${name}`);
toSet[`tags.${newname}`] = data.tags[name];
}
- await client.database.write(interaction.guild.id, toSet, toUnset);
+ await client.database.guilds.write(interaction.guild.id, toSet, toUnset);
} catch (e) {
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tag Edit")
.setDescription("Something went wrong and the tag was not edited")
.setStatus("Danger")
.setEmoji("PUNISH.NICKNAME.RED")
], components: []});
}
- return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ return await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Tags")
.setDescription("Tag edited successfully")
.setStatus("Success")
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index 5052a6b..a534791 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -1,8 +1,7 @@
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import keyValueList from "../../utils/generateKeyValueList.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
import { SelectMenuOption } from '@discordjs/builders';
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -25,10 +24,9 @@
.setName("list")
.setDescription("Lists all tags in the server")
-const callback = async (interaction: CommandInteraction) => {
- let data = await client.database.read(interaction.guild.id);
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ let data = await client.database.guilds.read(interaction.guild.id);
let tags = data.getKey("tags");
- console.log(tags)
let strings = []
if (data === {}) strings = ["*No tags exist*"]
else {
@@ -39,7 +37,6 @@
strings.push(string.slice(0, -1))
string = ""
}
- console.log(string)
string += proposed
}
strings.push(string.slice(0, -1))
@@ -48,7 +45,7 @@
let pages = []
for (let string of strings) {
pages.push(new Embed()
- .setEmbed(new generateEmojiEmbed()
+ .setEmbed(new EmojiEmbed()
.setTitle("Tags")
.setDescription(string)
.setEmoji("PUNISH.NICKNAME.GREEN")
@@ -58,7 +55,7 @@
let m;
m = await interaction.reply({
embeds: [
- new generateEmojiEmbed()
+ new EmojiEmbed()
.setTitle("Welcome")
.setDescription(`One moment...`)
.setStatus("Danger")
@@ -128,7 +125,7 @@
return;
}
}
- let em = new Discord.MessageEmbed(pages[page])
+ let em = new Discord.MessageEmbed(pages[page].embed)
em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
await interaction.editReply({
embeds: [em],
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 237623d..15abb0a 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -8,7 +8,7 @@
.setName("close")
.setDescription("Closes a ticket")
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
await close(interaction);
}
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 6567c49..c44e576 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -9,7 +9,7 @@
.setDescription("Creates a new modmail ticket")
.addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
await create(interaction)
}
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 0c7a3eb..8557d15 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
import createPageIndicator from "../../utils/createPageIndicator.js";
@@ -26,7 +26,7 @@
}
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser, renderDelta } = client.logger
let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
let flags: string[] = [];
@@ -105,7 +105,7 @@
let embeds = [
new Embed()
- .setEmbed(new generateEmojiEmbed()
+ .setEmbed(new EmojiEmbed()
.setTitle("User Info: General")
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
@@ -129,7 +129,7 @@
.setImage((await member.user.fetch()).bannerURL({format: "gif"}))
).setTitle("General").setDescription("General information about the user").setPageId(0),
new Embed()
- .setEmbed(new generateEmojiEmbed()
+ .setEmbed(new EmojiEmbed()
.setTitle("User Info: Roles")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
@@ -144,7 +144,7 @@
.setThumbnail(await member.user.displayAvatarURL({dynamic: true}))
).setTitle("Roles").setDescription("Roles the user has").setPageId(1),
new Embed()
- .setEmbed(new generateEmojiEmbed()
+ .setEmbed(new EmojiEmbed()
.setTitle("User Info: Key Permissions")
.setStatus("Success")
.setEmoji("GUILD.ROLES.CREATE")
@@ -158,7 +158,7 @@
).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2),
]
let m
- m = await interaction.reply({embeds: [new generateEmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true});
+ m = await interaction.reply({embeds: [new EmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true});
let page = 0
let breakReason = ""
while (true) {
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index 9a84118..e72506f 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -1,10 +1,10 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
-import client from "../../client.js"
+import client from "../../utils/client.js"
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -12,10 +12,10 @@
.setDescription("Shows the avatar of a user")
.addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"))
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger
let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("User Info")
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 0e6fafd..da332da 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,7 +1,7 @@
import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import addPlural from "../../utils/plurals.js";
import client from "../../utils/client.js";
@@ -21,12 +21,12 @@
return "TRACKS.VERTICAL.MIDDLE." + disabled + active
}
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
const { renderUser } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
- let config = await client.database.read(guild.id);
- await interaction.reply({embeds: [new generateEmojiEmbed()
+ let config = await client.database.guilds.read(guild.id);
+ await interaction.reply({embeds: [new EmojiEmbed()
.setEmoji("NUCLEUS.LOADING")
.setTitle("Loading")
.setStatus("Danger")
@@ -35,9 +35,11 @@
let generated;
const roles = await guild.roles.fetch()
let memberRoles = await member.roles
+ let managed
while (true) {
let data = config.tracks[track]
- let managed = data.manageableBy.some(element => {return memberRoles.cache.has(element)})
+ if (data.manageableBy !== undefined) managed = data.manageableBy.some(element => {return memberRoles.cache.has(element)})
+ else managed = false
let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
return new SelectMenuOption({
@@ -94,7 +96,7 @@
} else {
currentRoleIndex = selected.length == 0 ? -1 : data.track.indexOf(selected[0].toString())
}
- let m = await interaction.editReply({embeds: [new generateEmojiEmbed()
+ let m = await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("TRACKS.ICON")
.setTitle("Tracks")
.setDescription(`${generated}`)
@@ -160,16 +162,19 @@
}
const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let tracks = (await client.database.guilds.read(interaction.guild.id)).tracks
+ if (!tracks) throw "This server does not have any tracks"
let member = (interaction.member as GuildMember)
// Allow the owner to promote anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user can manage any of the tracks
- // @ts-ignore
- let tracks = (await client.database.get(interaction.guild.id)).tracks
let managed = false
- tracks.forEach(element => { if (element.track.manageableBy.some(role => member.roles.cache.has(role))) managed = true });
+ tracks.forEach(element => {
+ if (!element.track.manageableBy) return
+ if (element.track.manageableBy.some(role => member.roles.cache.has(role))) managed = true
+ });
// Check if the user has manage_roles permission
- if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the `manage_roles` permission";
+ if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
// Allow track
return true;
}
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index c9abb77..4ccc807 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -7,7 +7,7 @@
.setName("verify")
.setDescription("Get verified in the server")
-const callback = async (interaction: CommandInteraction) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
verify(interaction);
}