Performance testing
diff --git a/src/commands/help.ts b/src/commands/help.ts
index e85cf6b..c9bba7d 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -1,4 +1,4 @@
-import type { CommandInteraction } from "discord.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
const command = new SlashCommandBuilder()
@@ -6,7 +6,12 @@
.setDescription("Shows help for commands");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- interaction.reply("hel p D:"); // TODO: FINISH THIS FOR RELEASE
+ interaction.reply({components: [new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setLabel("Verify")
+ .setStyle(ButtonStyle.Primary)
+ .setCustomId("verifybutton")
+ )]}); // TODO: FINISH THIS FOR RELEASE
};
const check = (_interaction: CommandInteraction) => {
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index 987a1c1..af8006c 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -3,6 +3,6 @@
const name = "mod";
const description = "Perform moderator actions";
-const subcommand = await command(name, description, `mod`)
+const subcommand = await command(name, description, `mod`);
export { name, description, subcommand as command };
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 7346bcc..ba60d1e 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -74,6 +74,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
+ if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -83,7 +84,8 @@
.setEmoji("PUNISH.BAN.RED")
.setTitle("Banned")
.setDescription(
- `You have been banned in ${interaction.guild.name}` + (reason ? ` for:\n> ${reason}` : ".")
+ `You have been banned in ${interaction.guild.name}` +
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided.*")
)
.setStatus("Danger")
],
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 6b5c81e..fac87a0 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -23,6 +23,7 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("info")
+ // .setNameLocalizations({"ru": "about", "zh-CN": "history", "zh-TW": "notes", "pt-BR": "flags"})
.setDescription("Shows moderator information about a user")
.addUserOption((option) =>
option.setName("user").setDescription("The user to get information about").setRequired(true)
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index dd71892..88b6e14 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -75,6 +75,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
+ if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -85,7 +86,7 @@
.setTitle("Kicked")
.setDescription(
`You have been kicked from ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".\n*No reason was provided.*")
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided.*")
)
.setStatus("Danger")
],
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 05a9ec2..d68272b 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -13,6 +13,7 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("mute")
+ // .setNameLocalizations({"ru": "silence"})
.setDescription("Mutes a member, stopping them from talking in the server")
.addUserOption((option) => option.setName("user").setDescription("The user to mute").setRequired(true))
.addIntegerOption((option) =>
@@ -234,6 +235,7 @@
let dmMessage;
try {
if (notify) {
+ if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -244,7 +246,7 @@
.setTitle("Muted")
.setDescription(
`You have been muted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".\n*No reason was provided*") + "\n\n" +
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") + "\n\n" +
`You will be unmuted at: <t:${Math.round(new Date().getTime() / 1000) + muteTime}:D> at ` +
`<t:${Math.round(new Date().getTime() / 1000) + muteTime}:T> (<t:${Math.round(new Date().getTime() / 1000) + muteTime
}:R>)` + "\n\n" +
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 0975375..81935a2 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,4 +1,4 @@
-import { CommandInteraction, GuildMember } from "discord.js";
+import type { CommandInteraction, GuildMember } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -8,6 +8,7 @@
const command = (builder: SlashCommandSubcommandBuilder) => builder
.setName("nick")
+ // .setNameLocalizations({"ru": "name", "zh-CN": "nickname"})
.setDescription("Changes a users nickname")
.addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
.addStringOption((option) =>
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index 6087890..3020eb8 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -29,11 +29,7 @@
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(
- channel.type.toString()
- )
- ) {
+ if (channel.isTextBased()) {
return await interaction.reply({
embeds: [
new EmojiEmbed()
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 390baa5..d920bb0 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -84,6 +84,7 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
+ if (reason) { reason = reason.split("\n").map((line) => "> " + line).join("\n") }
const messageData: {
embeds: EmojiEmbed[];
components: ActionRowBuilder<ButtonBuilder>[];
@@ -94,7 +95,7 @@
.setTitle("Warned")
.setDescription(
`You have been warned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".\n*No reason was provided*") +
+ (reason ? ` for:\n${reason}` : ".\n*No reason was provided*") +
"\n\n" +
(createAppealTicket
? `You can appeal this in the ticket created in <#${confirmation.components!["appeal"]!.response}>`
diff --git a/src/commands/nucleus/_meta.ts b/src/commands/nucleus/_meta.ts
index d66b5d2..521b338 100644
--- a/src/commands/nucleus/_meta.ts
+++ b/src/commands/nucleus/_meta.ts
@@ -5,4 +5,6 @@
const subcommand = await command(name, description, `nucleus`)
-export { name, description, subcommand as command };
+const allowedInDMs = true;
+
+export { name, description, subcommand as command, allowedInDMs };
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index ffc441a..d3370ba 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -1,11 +1,12 @@
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { CommandInteraction } from 'discord.js';
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import guide from "../../reflex/guide.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("guide").setDescription("Shows the welcome guide for the bot");
-const callback = async (interaction) => {
- guide(interaction.guild, interaction);
+const callback = async (interaction: CommandInteraction) => {
+ guide(interaction.guild!, interaction);
};
const check = () => {
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index 7c36d62..fd65e51 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -1,5 +1,5 @@
import { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -16,12 +16,12 @@
.setStatus("Danger")
],
components: [
- new ActionRowBuilder().addComponents([
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setLabel("Invite")
.setStyle(ButtonStyle.Link)
.setURL(
- `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=295157886134&scope=bot%20applications.commands`
+ `https://discord.com/api/oauth2/authorize?client_id=${client.user!.id}&permissions=295157886134&scope=bot%20applications.commands`
)
])
],
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 59b6393..3cbd049 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,6 +1,6 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { CommandInteraction } from "discord.js";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -19,8 +19,8 @@
.setTitle("Ping")
.setDescription(
`**Ping:** \`${ping}ms\`\n` +
- `**To Discord:** \`${client.ws.ping}ms\`\n` +
- `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
+ `**To Discord:** \`${client.ws.ping}ms\`\n` +
+ `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
)
.setEmoji("CHANNEL.SLOWMODE.OFF")
.setStatus("Danger")
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index a67cd36..d8b2807 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -1,5 +1,5 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { CommandInteraction } from "discord.js";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 49c80fb..a75e8a0 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -1,4 +1,5 @@
-import Discord, { CommandInteraction } from "discord.js";
+import type { CommandInteraction } from "discord.js";
+import type Discord from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -13,8 +14,9 @@
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
+ await interaction.guild?.members.fetch(interaction.member!.user.id)
const { renderUser } = client.logger;
- const suggestion = interaction.options.getString("suggestion");
+ const suggestion = interaction.options.get("suggestion")?.value as string;
const confirmation = await new confirmationMessage(interaction)
.setEmoji("ICONS.OPP.ADD")
.setTitle("Suggest")
@@ -32,7 +34,7 @@
new EmojiEmbed()
.setTitle("Suggestion")
.setDescription(
- `**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`
+ `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}`
)
.setStatus("Danger")
.setEmoji("NUCLEUS.LOGO")
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index b895768..e5bea60 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -1,4 +1,4 @@
-import type { CommandInteraction } from "discord.js";
+import { CommandInteraction, GuildMFALevel } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -8,6 +8,28 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("about").setDescription("Shows info about the server");
+
+const verificationTypes = {
+ 0: "None - Unrestricted",
+ 1: "Low - Must have a verified email",
+ 2: "Medium - Must be registered for 5 minutes",
+ 3: "High - Must be a member for 10 minutes",
+ 4: "Highest - Must have a verified phone"
+}
+
+const premiumTiers = {
+ 0: "None",
+ 1: "Tier 1",
+ 2: "Tier 2",
+ 3: "Tier 3"
+}
+
+const filterLevels = {
+ 0: "Disabled",
+ 1: "Members without roles",
+ 2: "All members"
+}
+
const callback = async (interaction: CommandInteraction): Promise<void> => {
const guild = interaction.guild!;
const { renderUser, renderDelta } = client.logger;
@@ -27,28 +49,26 @@
`${guild.emojis.cache.size}` +
(guild.emojis.cache.size > 1
? `\n> ${guild.emojis.cache
- .first(10)
- .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
- .join(" ")}` +
- (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
+ .first(10)
+ .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
+ .join(" ")}` +
+ (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
: ""),
icon: `[Discord](${guild.iconURL()})`,
"2 factor authentication": `${
- guild.mfaLevel === "NONE"
+ guild.mfaLevel === GuildMFALevel.None
? `${getEmojiByName("CONTROL.CROSS")} No`
: `${getEmojiByName("CONTROL.TICK")} Yes`
}`,
- "verification level": `${toCapitals(guild.verificationLevel)}`,
- "explicit content filter": `${toCapitals(
- guild.explicitContentFilter.toString().replace(/_/, " ")
- )}`,
- "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
+ "verification level": `${toCapitals(verificationTypes[guild.verificationLevel])}`,
+ "explicit content filter": `${filterLevels[guild.explicitContentFilter]}`,
+ "nitro boost level": `${premiumTiers[guild.premiumTier]}`,
channels: `${guild.channels.cache.size}`,
roles: `${guild.roles.cache.size}`,
members: `${guild.memberCount}`
})
)
- .setThumbnail(guild.iconURL({ dynamic: true }))
+ .setThumbnail(guild.iconURL())
],
ephemeral: true
});
diff --git a/src/commands/settings/_meta.ts b/src/commands/settings/_meta.ts
index 76e570d..666dbf4 100644
--- a/src/commands/settings/_meta.ts
+++ b/src/commands/settings/_meta.ts
@@ -4,6 +4,8 @@
const description = "Change bot settings";
-const subcommand = await command(name, description, "settings")
+const subcommand = await command(name, description, "settings", undefined, undefined, undefined, [
+ "ManageGuild"
+])
export { name, description, subcommand as command};
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index f19998a..a768cb8 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -224,6 +224,16 @@
return true;
};
+const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
+ if (!interaction.guild) return [];
+ const prompt = interaction.options.getString("tag");
+ // generateStatsChannelAutocomplete(int.options.getString("name") ?? "")
+ const results = generateStatsChannelAutocomplete(prompt ?? "");
+ return results;
+};
+
+
+
export { command };
export { callback };
export { check };
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 5284f8a..7f02cd7 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -7,7 +7,8 @@
ButtonBuilder,
MessageComponentInteraction,
Role,
- ButtonStyle
+ ButtonStyle,
+ AutocompleteInteraction
} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -204,7 +205,7 @@
.setEmoji("CHANNEL.TEXT.CREATE")
],
components: [
- new ActionRowBuilder().addComponents([
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setLabel(lastClicked == "clear-message" ? "Click again to confirm" : "Clear Message")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
@@ -296,11 +297,42 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
- if (!member.permissions.has("MANAGE_GUILD"))
+ if (!member.permissions.has("ManageGuild"))
throw new Error("You must have the *Manage Server* permission to use this command");
return true;
};
-export { command };
-export { callback };
-export { check };
+const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
+ const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"]
+ if (!interaction.guild) return [];
+ const prompt = interaction.options.getString("message");
+ const autocompletions = [];
+ if ( prompt === null ) {
+ for (const replacement of validReplacements) {
+ autocompletions.push(`{${replacement}}`);
+ };
+ return autocompletions;
+ };
+ const beforeLastOpenBracket = prompt.match(/(.*){[^{}]{0,15}$/);
+ const afterLastOpenBracket = prompt.match(/{[^{}]{0,15}$/);
+ if (beforeLastOpenBracket !== null) {
+ if (afterLastOpenBracket !== null) {
+ for (const replacement of validReplacements) {
+ if (replacement.startsWith(afterLastOpenBracket[0].slice(1))) {
+ autocompletions.push(`${beforeLastOpenBracket[1]}{${replacement}}`);
+ }
+ }
+ } else {
+ for (const replacement of validReplacements) {
+ autocompletions.push(`${beforeLastOpenBracket[1]}{${replacement}}`);
+ }
+ }
+ } else {
+ for (const replacement of validReplacements) {
+ autocompletions.push(`${prompt} {${replacement}}`);
+ }
+ }
+ return autocompletions;
+};
+
+export { command, callback, check, autocomplete };
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 859b7fc..a65947c 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -58,10 +58,8 @@
const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
if (!interaction.guild) return [];
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;
};
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 72ad1eb..aa45690 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -79,7 +79,7 @@
Staff: "Discord Staff",
VerifiedDeveloper: "Verified Bot Developer",
ActiveDeveloper: "Active Developer",
- Quarantined: "Quarantined [What does this mean?](https://support.discord.com/hc/en-us/articles/6461420677527)",
+ Quarantined: "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
Spammer: "Likely Spammer"
// CertifiedModerator
// VerifiedBot