More commands fixed and purge to here
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index e32a720..7346bcc 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -53,6 +53,7 @@
false,
undefined,
"The user will be sent a DM",
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 12c414f..6e9abed 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
import type { HistorySchema } from "../../utils/database.js";
import Discord, {
CommandInteraction,
@@ -8,11 +9,12 @@
ButtonBuilder,
MessageComponentInteraction,
ModalSubmitInteraction,
- TextInputComponent,
ButtonStyle,
- StringSelectMenuInteraction
+ StringSelectMenuInteraction,
+ TextInputStyle,
+ APIMessageComponentEmoji
} from "discord.js";
-import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder, StringSelectMenuOptionBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import client from "../../utils/client.js";
@@ -153,60 +155,59 @@
}
}
if (pageIndex === null) pageIndex = 0;
- const components = (
- openFilterPane
- ? [
- new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
- new Discord.SelectMenuBuilder()
- .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 ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setCustomId("prevYear")
- .setLabel((currentYear - 1).toString())
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder().setCustomId("prevPage").setLabel("Previous page").setStyle(ButtonStyle.Primary),
- new ButtonBuilder().setCustomId("today").setLabel("Today").setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("nextPage")
- .setLabel("Next page")
- .setStyle(ButtonStyle.Primary)
- .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
- new ButtonBuilder()
- .setCustomId("nextYear")
- .setLabel((currentYear + 1).toString())
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(currentYear === new Date().getFullYear())
- ]),
- new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setLabel("Mod notes")
- .setCustomId("modNotes")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
- new ButtonBuilder()
- .setLabel("Filter")
- .setCustomId("openFilter")
- .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
- ])
- ]);
+ let components: (ActionRowBuilder<Discord.StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[] = []
+ if (openFilterPane) components = components.concat([
+ new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents(
+ new Discord.StringSelectMenuBuilder().setOptions(
+ ...Object.entries(types).map(([key, value]) => new StringSelectMenuOptionBuilder()
+ .setLabel(value.text)
+ .setValue(key)
+ .setDefault(filteredTypes.includes(key))
+ .setEmoji(client.emojis.resolve(getEmojiByName(value.emoji, "id"))! as APIMessageComponentEmoji)
+ )
+ )
+ .setMinValues(1)
+ .setMaxValues(Object.keys(types).length)
+ .setCustomId("filter")
+ .setPlaceholder("Select events to show")
+ )
+ ])
+ components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setCustomId("prevYear")
+ .setLabel((currentYear - 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+ .setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder()
+ .setCustomId("prevPage")
+ .setLabel("Previous page")
+ .setStyle(ButtonStyle.Primary),
+ new ButtonBuilder().setCustomId("today").setLabel("Today").setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId("nextPage")
+ .setLabel("Next page")
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(pageIndex >= groups.length - 1 && currentYear === new Date().getFullYear()),
+ new ButtonBuilder()
+ .setCustomId("nextYear")
+ .setLabel((currentYear + 1).toString())
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(currentYear === new Date().getFullYear())
+ ])])
+ components = components.concat([new ActionRowBuilder<Discord.ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setLabel("Mod notes")
+ .setCustomId("modNotes")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id")),
+ new ButtonBuilder()
+ .setLabel("Filter")
+ .setCustomId("openFilter")
+ .setStyle(openFilterPane ? ButtonStyle.Success : ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
+ ])])
+
const end =
"\n\nJanuary " +
currentYear.toString() +
@@ -216,7 +217,7 @@
currentYear.toString();
if (groups.length > 0) {
const toRender = groups[Math.min(pageIndex, groups.length - 1)]!;
- m = (await interaction.editReply({
+ m = await interaction.editReply({
embeds: [
new EmojiEmbed()
.setEmoji("MEMBER.JOIN")
@@ -226,25 +227,25 @@
)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : ""
+ text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
})
],
components: components
- })) as Message;
+ });
} else {
- m = (await interaction.editReply({
+ 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)
+ .setDescription(`**${currentYear}**\n\n*No events*`)
.setStatus("Success")
.setFooter({
- text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : ""
+ text: openFilterPane && filteredTypes.length ? "Filters are currently enabled" : "No filters selected"
})
],
components: components
- })) as Message;
+ })
}
let i: MessageComponentInteraction;
try {
@@ -315,7 +316,7 @@
let m: Message;
const member = interaction.options.getMember("user") as Discord.GuildMember;
await interaction.reply({
- embeds: [new EmojiEmbed().setEmoji("NUCLEUS.LOADING").setTitle("Downloading Data").setStatus("Danger")],
+ embeds: LoadingEmbed,
ephemeral: true,
fetchReply: true
});
@@ -324,9 +325,7 @@
let timedOut = false;
while (!timedOut) {
note = await client.database.notes.read(member.guild.id, member.id);
- if (firstLoad && !note) {
- await showHistory(member, interaction);
- }
+ if (firstLoad && !note) { await showHistory(member, interaction); }
firstLoad = false;
m = (await interaction.editReply({
embeds: [
@@ -344,7 +343,7 @@
.setCustomId("modify")
.setEmoji(getEmojiByName("ICONS.EDIT", "id")),
new ButtonBuilder()
- .setLabel("View moderation history")
+ .setLabel("Moderation history")
.setStyle(ButtonStyle.Primary)
.setCustomId("history")
.setEmoji(getEmojiByName("ICONS.HISTORY", "id"))
@@ -364,14 +363,14 @@
.setCustomId("modal")
.setTitle("Editing moderator note")
.addComponents(
- new ActionRowBuilder<Discord.TextInputComponent>().addComponents(
- new TextInputComponent()
+ new ActionRowBuilder<Discord.TextInputBuilder>().addComponents(
+ new Discord.TextInputBuilder()
.setCustomId("note")
.setLabel("Note")
.setMaxLength(4000)
.setRequired(false)
- .setStyle("PARAGRAPH")
- .setValue(note ? note : "")
+ .setStyle(TextInputStyle.Paragraph)
+ .setValue(note ? note : " ")
)
)
);
@@ -408,7 +407,9 @@
if (out === null) {
continue;
} else if (out instanceof ModalSubmitInteraction) {
- const toAdd = out.fields.getTextInputValue("note") || null;
+ let toAdd = out.fields.getTextInputValue("note") || null;
+ if (toAdd === " ") toAdd = null;
+ if (toAdd) toAdd = toAdd.trim();
await client.database.notes.create(member.guild.id, member.id, toAdd);
} else {
continue;
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 2feb5d7..dd71892 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,4 +1,4 @@
-import { LinkWarningFooter } from './../../utils/defaultEmbeds';
+import { LinkWarningFooter } from './../../utils/defaultEmbeds.js';
import { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
@@ -42,6 +42,7 @@
false,
null,
"The user will be sent a DM",
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 0e76cba..95c8c5a 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -192,6 +192,7 @@
async () =>
await create(interaction.guild, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
+ null,
"CONTROL.TICKET",
createAppealTicket
)
@@ -201,6 +202,7 @@
false,
undefined,
null,
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index b5e5554..0975375 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -45,6 +45,7 @@
false,
null,
null,
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index e9aa41a..6087890 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,4 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle } from "discord.js";
+import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle, ButtonBuilder } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -26,7 +26,8 @@
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const user = (interaction.options.getMember("user") as GuildMember);
+ if (!interaction.guild) return;
+ const user = (interaction.options.getMember("user") as GuildMember | null);
const channel = interaction.channel as GuildChannel;
if (
!["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(
@@ -46,7 +47,7 @@
});
}
// TODO:[Modals] Replace this with a modal
- if (!interaction.options.getInteger("amount")) {
+ if (!interaction.options.get("amount")) {
await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -74,17 +75,17 @@
.setStatus("Danger")
],
components: [
- new Discord.ActionRowBuilder().addComponents([
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder().setCustomId("1").setLabel("1").setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("3").setLabel("3").setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("5").setLabel("5").setStyle(ButtonStyle.Secondary)
]),
- new Discord.ActionRowBuilder().addComponents([
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder().setCustomId("10").setLabel("10").setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("25").setLabel("25").setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder().setCustomId("50").setLabel("50").setStyle(ButtonStyle.Secondary)
]),
- new Discord.ActionRowBuilder().addComponents([
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder()
.setCustomId("done")
.setLabel("Done")
@@ -110,16 +111,14 @@
}
const amount = parseInt((await component).customId);
- let messages;
+ let messages: Discord.Message[] = [];
await (interaction.channel as TextChannel).messages.fetch({ limit: amount }).then(async (ms) => {
if (user) {
ms = ms.filter((m) => m.author.id === user.id);
}
- messages = await (channel as TextChannel).bulkDelete(ms, true);
+ messages = (await (channel as TextChannel).bulkDelete(ms, true)).map(m => m as Discord.Message);
});
- if (messages) {
- deleted = deleted.concat(messages.map((m) => m));
- }
+ deleted = deleted.concat(messages);
}
if (deleted.length === 0)
return await interaction.editReply({
@@ -136,11 +135,12 @@
await client.database.history.create(
"purge",
interaction.guild.id,
- user,
- interaction.options.getString("reason"),
+ user.user,
+ interaction.user,
+ (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
null,
null,
- deleted.length
+ deleted.length.toString()
);
}
const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
@@ -156,8 +156,8 @@
list: {
memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
- messagesCleared: entry(deleted.length, deleted.length)
+ channel: entry(interaction.channel!.id, renderChannel(interaction.channel! as GuildChannel)),
+ messagesCleared: entry(deleted.length.toString(), deleted.length.toString())
},
hidden: {
guild: interaction.guild.id
@@ -189,7 +189,7 @@
.setStatus("Success")
],
components: [
- new Discord.ActionRowBuilder().addComponents([
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder()
.setCustomId("download")
.setLabel("Download transcript")
@@ -207,7 +207,7 @@
} catch {
return;
}
- if (component && component.customId === "download") {
+ if (component.customId === "download") {
interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -239,12 +239,8 @@
.setDescription(
keyValueList({
channel: `<#${channel.id}>`,
- amount: interaction.options.getInteger("amount").toString(),
- reason: `\n> ${
- interaction.options.getString("reason")
- ? interaction.options.getString("reason")
- : "*No reason provided*"
- }`
+ amount: (interaction.options.get("amount")?.value as number).toString(),
+ reason: `\n> ${interaction.options.get("reason")?.value ? interaction.options.get("reason")?.value : "*No reason provided*"}`
})
)
.setColor("Danger")
@@ -255,7 +251,7 @@
try {
if (!user) {
const toDelete = await (interaction.channel as TextChannel).messages.fetch({
- limit: interaction.options.getInteger("amount")
+ limit: interaction.options.get("amount")?.value as number
});
messages = await (channel as TextChannel).bulkDelete(toDelete, true);
} else {
@@ -265,7 +261,7 @@
limit: 100
})
).filter((m) => m.author.id === user.id)
- ).first(interaction.options.getInteger("amount"));
+ ).first(interaction.options.get("amount")?.value as number);
messages = await (channel as TextChannel).bulkDelete(toDelete, true);
}
} catch (e) {
@@ -280,15 +276,29 @@
components: []
});
}
+ if (!messages) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.PURGE.RED")
+ .setTitle("Purge")
+ .setDescription("No messages could be deleted")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ return;
+ }
if (user) {
await client.database.history.create(
"purge",
interaction.guild.id,
- user,
- interaction.options.getString("reason"),
+ user.user,
+ interaction.user,
+ (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
null,
null,
- messages.size
+ messages.size.toString()
);
}
const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
@@ -304,8 +314,8 @@
list: {
memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
- messagesCleared: entry(messages.size, messages.size)
+ channel: entry(interaction.channel!.id, renderChannel(interaction.channel! as GuildChannel)),
+ messagesCleared: entry(messages.size.toString(), messages.size.toString())
},
hidden: {
guild: interaction.guild.id
@@ -314,14 +324,26 @@
log(data);
let out = "";
messages.reverse().forEach((message) => {
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(
- message.createdTimestamp
- ).toISOString()}]\n`;
- const lines = message.content.split("\n");
- lines.forEach((line) => {
- out += `> ${line}\n`;
- });
- out += "\n\n";
+ if (!message) {
+ out += "Unknown message\n\n"
+ } else {
+ const author = message.author ?? { username: "Unknown", discriminator: "0000", id: "Unknown" };
+ out += `${author.username}#${author.discriminator} (${author.id}) [${new Date(
+ message.createdTimestamp
+ ).toISOString()}]\n`;
+ if (message.content) {
+ const lines = message.content.split("\n");
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
+ }
+ if (message.attachments.size > 0) {
+ message.attachments.forEach((attachment) => {
+ out += `Attachment > ${attachment.url}\n`;
+ });
+ }
+ out += "\n\n";
+ }
});
const attachmentObject = {
attachment: Buffer.from(out),
@@ -337,7 +359,7 @@
.setStatus("Success")
],
components: [
- new Discord.ActionRowBuilder().addComponents([
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
new Discord.ButtonBuilder()
.setCustomId("download")
.setLabel("Download transcript")
@@ -355,7 +377,7 @@
} catch {
return;
}
- if (component && component.customId === "download") {
+ if (component.customId === "download") {
interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -395,14 +417,15 @@
};
const check = (interaction: CommandInteraction) => {
+ if (!interaction.guild) return false;
const member = interaction.member as GuildMember;
- const me = interaction.guild.me!;
+ const me = interaction.guild.members.me!;
// Check if nucleus has the manage_messages permission
- if (!me.permissions.has("MANAGE_MESSAGES")) throw new Error("I do not have the *Manage Messages* permission");
+ if (!me.permissions.has("ManageMessages")) throw new Error("I do not have the *Manage Messages* permission");
// Allow the owner to purge
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_messages permission
- if (!member.permissions.has("MANAGE_MESSAGES")) throw new Error("You do not have the *Manage Messages* permission");
+ if (!member.permissions.has("ManageMessages")) throw new Error("You do not have the *Manage Messages* permission");
// Allow purge
return true;
};
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index c9a71f6..12bfc3e 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -51,6 +51,7 @@
false,
null,
null,
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 40510a8..c93f8cc 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -38,6 +38,7 @@
false,
null,
"The user will be sent a DM",
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 1c5223f..390baa5 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -41,6 +41,7 @@
!(await areTicketsEnabled(interaction.guild.id)),
async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created",
+ null,
"CONTROL.TICKET",
createAppealTicket
)
@@ -50,6 +51,7 @@
false,
null,
"The user will be sent a DM",
+ null,
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index c54d7ab..859b7fc 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -2,6 +2,8 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import client from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+import { capitalize } from "../utils/generateKeyValueList.js";
+import { getResults } from "../utils/search.js";
const command = new SlashCommandBuilder()
.setName("tag")
@@ -9,41 +11,44 @@
.addStringOption((o) => o.setName("tag").setDescription("The tag to get").setAutocomplete(true).setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
- const config = await client.database.guilds.read(interaction.guild.id);
- const tags = config.getKey("tags");
- const tag = tags[interaction.options.getString("tag")];
+ const config = await client.database.guilds.read(interaction.guild!.id);
+ const tags = config.tags;
+ const search = interaction.options.get("tag")?.value as string;
+ const tag = tags[search];
if (!tag) {
- return await interaction.reply({
+ await interaction.reply({
embeds: [
new EmojiEmbed()
.setTitle("Tag")
- .setDescription(`Tag \`${interaction.options.get("tag")}\` does not exist`)
+ .setDescription(`Tag \`${search}\` does not exist`)
.setEmoji("PUNISH.NICKNAME.RED")
.setStatus("Danger")
],
ephemeral: true
});
+ return;
}
let url = "";
- let components: ActionRowBuilder[] = [];
+ let components: ActionRowBuilder<ButtonBuilder>[] = [];
if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
url = tag;
components = [
- new ActionRowBuilder().addComponents([new ButtonBuilder().setLabel("Open").setURL(url).setStyle(ButtonStyle.Link)])
+ new ActionRowBuilder<ButtonBuilder>().addComponents([new ButtonBuilder().setLabel("Open").setURL(url).setStyle(ButtonStyle.Link)])
];
}
- return await interaction.reply({
- embeds: [
- new EmojiEmbed()
- .setTitle(interaction.options.get("tag").value)
- .setDescription(tag)
- .setEmoji("PUNISH.NICKNAME.GREEN")
- .setStatus("Success")
- .setImage(url)
- ],
+ const em = new EmojiEmbed()
+ .setTitle(capitalize(search))
+ .setEmoji("PUNISH.NICKNAME.GREEN")
+ .setStatus("Success")
+ if (url) em.setImage(url)
+ else em.setDescription(tag);
+
+ await interaction.reply({
+ embeds: [em],
components: components,
ephemeral: true
});
+ return;
};
const check = () => {
@@ -52,9 +57,12 @@
const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
if (!interaction.guild) return [];
- const config = await client.database.guilds.read(interaction.guild.id);
- const tags = Object.keys(config.getKey("tags"));
- return tags;
+ const prompt = interaction.options.getString("tag");
+ console.log(prompt)
+ const possible = Object.keys((await client.memory.readGuildInfo(interaction.guild.id)).tags);
+ const results = getResults(prompt ?? "", possible);
+ console.log(results)
+ return results;
};
export { command };
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index b922da3..5379bf8 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -16,8 +16,8 @@
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const name = interaction.options.getString("name");
- const value = interaction.options.getString("value");
+ const name = interaction.options.get("name")?.value as string;
+ const value = interaction.options.get("value")?.value as string;
if (name!.length > 100)
return await interaction.reply({
embeds: [
@@ -41,7 +41,7 @@
ephemeral: true
});
const data = await client.database.guilds.read(interaction.guild!.id);
- if (data.tags.length >= 100)
+ if (Object.keys(data.tags).length >= 100)
return await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -90,6 +90,7 @@
await client.database.guilds.write(interaction.guild!.id, {
[`tags.${name}`]: value
});
+ await client.memory.forceUpdate(interaction.guild!.id);
} catch (e) {
return await interaction.editReply({
embeds: [
@@ -116,7 +117,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
- if (!member.permissions.has("MANAGE_MESSAGES"))
+ if (!member.permissions.has("ManageMessages"))
throw new Error("You must have the *Manage Messages* permission to use this command");
return true;
};
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index 2fff637..6d76eb1 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -13,7 +13,7 @@
.addStringOption((o) => o.setName("name").setRequired(true).setDescription("The name of the tag"));
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const name = interaction.options.getString("name");
+ const name = interaction.options.get("name")?.value as string;
const data = await client.database.guilds.read(interaction.guild!.id);
if (!data.tags[name])
return await interaction.reply({
@@ -51,6 +51,7 @@
});
try {
await client.database.guilds.write(interaction.guild!.id, null, ["tags." + name]);
+ await client.memory.forceUpdate(interaction.guild!.id);
} catch (e) {
console.log(e);
return await interaction.editReply({
@@ -78,7 +79,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
- if (!member.permissions.has("MANAGE_MESSAGES"))
+ if (!member.permissions.has("ManageMessages"))
throw new Error("You must have the *Manage Messages* permission to use this command");
return true;
};
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 376abbd..018a0bb 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -110,6 +110,7 @@
toSet[`tags.${newname}`] = data.tags[name];
}
await client.database.guilds.write(interaction.guild.id, toSet === {} ? null : toSet, toUnset);
+ await client.memory.forceUpdate(interaction.guild!.id);
} catch (e) {
return await interaction.editReply({
embeds: [
@@ -136,7 +137,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- if (!member.permissions.has("MANAGE_MESSAGES"))
+ if (!member.permissions.has("ManageMessages"))
throw new Error("You must have the *Manage Messages* permission to use this command");
return true;
};
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index f94fb24..72ad1eb 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
+import { LoadingEmbed, Embed } from "./../../utils/defaultEmbeds.js";
import Discord, {
CommandInteraction,
GuildMember,
@@ -25,30 +25,6 @@
option.setName("user").setDescription("The user to get info about | Default: Yourself")
);
-class Embed {
- embed: EmojiEmbed = new EmojiEmbed();
- title: string = "";
- description = "";
- pageId = 0;
-
- setEmbed(embed: EmojiEmbed) {
- this.embed = embed;
- return this;
- }
- setTitle(title: string) {
- this.title = title;
- return this;
- }
- setDescription(description: string) {
- this.description = description;
- return this;
- }
- setPageId(pageId: number) {
- this.pageId = pageId;
- return this;
- }
-}
-
const callback = async (interaction: CommandInteraction): Promise<void> => {
const guild = interaction.guild!;
const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember;
@@ -101,11 +77,11 @@
BugHunterLevel2: "Bug Hunter Level 2",
Partner: "Partnered Server Owner",
Staff: "Discord Staff",
- VerifiedDeveloper: "Verified Bot Developer"
- // ActiveDeveloper
+ VerifiedDeveloper: "Verified Bot Developer",
+ ActiveDeveloper: "Active Developer",
+ Quarantined: "Quarantined [What does this mean?](https://support.discord.com/hc/en-us/articles/6461420677527)",
+ Spammer: "Likely Spammer"
// CertifiedModerator
- // Quarantined https://discord-api-types.dev/api/discord-api-types-v10/enum/UserFlags#Quarantined
- // Spammer https://discord-api-types.dev/api/discord-api-types-v10/enum/UserFlags#Spammer
// VerifiedBot
};
const members = await guild.members.fetch();
@@ -121,8 +97,8 @@
let s = "";
let count = 0;
let ended = false;
- for (const roleId in roles) {
- const string = `<@&${roleId}>, `;
+ for (const roleId of roles) {
+ const string = `<@&${roleId[1].id}>, `;
if (s.length + string.length > 1000) {
ended = true;
s += `and ${roles.size - count} more`;