Performance testing
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 };