Coded wanted to host the liveshare
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 2709bee..6fb2461 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -60,7 +60,7 @@
`Are you sure you want to set the attachment log channel to <#${channel.id}>?`
)
.setColor("Warning")
- .setFailedMessage("Attachment log channel not set", "Warning", "CHANNEL.TEXT.DELETE")
+ .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 992491a..9b594e8 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -56,7 +56,7 @@
.setTitle("Log Channel")
.setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
.setColor("Warning")
- .setFailedMessage("The log channel was not changed", "Danger", "CHANNEL.TEXT.DELETE")
+ .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 13125ef..3a0f395 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -61,7 +61,7 @@
`Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
)
.setColor("Warning")
- .setFailedMessage("Staff notifications channel not set", "Warning", "CHANNEL.TEXT.DELETE")
+ .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index cdd218b..1093bd2 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, Message, ActionRowBuilder, GuildMember, StringSelectMenuBuilder, StringSelectMenuInteraction, AutocompleteInteraction } from "discord.js";
+import Discord, { CommandInteraction, Message, ActionRowBuilder, GuildMember, StringSelectMenuBuilder, StringSelectMenuInteraction, SelectMenuOptionBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -12,214 +12,34 @@
builder
.setName("stats")
.setDescription("Controls channels which update when someone joins or leaves the server")
- .addChannelOption((option) => option.setName("channel").setDescription("The channel to modify"))
- .addStringOption((option) =>
- option
- .setName("name")
- .setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}")
- .setAutocomplete(true)
- );
-const callback = async (interaction: CommandInteraction): Promise<unknown> => { // TODO: This command feels unintuitive. Clicking a channel in the select menu deletes it
- // instead, it should give a submenu to edit the channel, enable/disable or delete it
- singleNotify("statsChannelDeleted", interaction.guild!.id, true);
- const m = (await interaction.reply({
- embeds: LoadingEmbed,
- ephemeral: true,
- fetchReply: true
- })) as Message;
- let config = await client.database.guilds.read(interaction.guild!.id);
- if (interaction.options.get("name")?.value as string) {
- let channel;
- if (Object.keys(config.stats).length >= 25) {
- return await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Stats Channel")
- .setDescription("You can only have 25 stats channels in a server")
- .setStatus("Danger")
- ]
- });
+const callback = async (interaction: CommandInteraction) => {
+ if (!interaction.guild) return;
+ let closed = false;
+ let page = 0;
+ do {
+ const config = await client.database.guilds.read(interaction.guild.id);
+ const stats = config.stats; // stats: Record<string, { name: string; enabled: boolean }>
+ if (!stats) {
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Stats channels")
+ .setDescription("You don't have ant stats channels yet")
+ .setStatus("Success")
+ .setEmoji("")
+ ]})
}
- try {
- channel = interaction.options.get("channel")?.channel as Discord.Channel;
- } catch {
- return await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Stats Channel")
- .setDescription("The channel you provided is not a valid channel")
- .setStatus("Danger")
- ]
- });
- }
- channel = channel as Discord.TextChannel;
- if (channel.guild.id !== interaction.guild!.id) {
- return interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription("You must choose a channel in this server")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]
- });
- }
- let newName = await convertCurlyBracketString(
- interaction.options.get("name")?.value as string,
- "",
- "",
- interaction.guild!.name,
- interaction.guild!.members
- );
- if (interaction.options.get("channel")?.channel!.type === Discord.ChannelType.GuildText) {
- newName = newName.toLowerCase().replace(/[\s]/g, "-");
- }
- const confirmation = await new confirmationMessage(interaction)
- .setEmoji("CHANNEL.TEXT.EDIT")
- .setTitle("Stats Channel")
- .setDescription(
- `Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(
- /^ +| $/g,
- ""
- )}*`
- )
- .setColor("Warning")
- .setInverted(true)
- .setFailedMessage(`Could not convert <#${channel.id}> to a stats chanel.`, "Danger", "CHANNEL.TEXT.DELETE")
- .send(true);
- if (confirmation.cancelled) return;
- if (confirmation.success) {
- try {
- const name = interaction.options.get("name")?.value as string;
- const channel = interaction.options.get("channel")?.channel as Discord.TextChannel;
- await client.database.guilds.write(interaction.guild!.id, {
- [`stats.${channel.id}`]: { name: name, enabled: true }
- });
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
- const data = {
- meta: {
- type: "statsChannelUpdate",
- displayName: "Stats Channel Updated",
- calculateType: "nucleusSettingsUpdated",
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
- channel: entry(channel.id, renderChannel(channel)),
- name: entry(
- interaction.options.get("name")?.value as string,
- `\`${interaction.options.get("name")?.value as string}\``
- )
- },
- hidden: {
- guild: interaction.guild!.id
- }
- };
- log(data);
- } catch (e) {
- console.log(e);
- return interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription("Something went wrong and the stats channel could not be set")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ],
- components: []
- });
- }
- } else {
- return interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ],
- components: []
- });
- }
- await statsChannelAddCallback(client, interaction.member as GuildMember);
- }
- let timedOut = false;
- while (!timedOut) {
- config = await client.database.guilds.read(interaction.guild!.id);
- const stats = config.stats;
- const selectMenu = new StringSelectMenuBuilder()
- .setCustomId("remove")
+ let pageSelect = new StringSelectMenuBuilder()
+ .setCustomId("page")
+ .setPlaceholder("Select a stats channel to manage")
.setMinValues(1)
- .setMaxValues(Math.max(1, Object.keys(stats).length));
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setTitle("Stats Channel")
- .setDescription(
- "The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list."
- )
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ],
- components: [
- new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
- Object.keys(stats).length
- ? [
- selectMenu
- .setPlaceholder("Select a stats channel to remove, stopping it updating")
- .addOptions(
- Object.keys(stats).map((key) => ({
- label: interaction.guild!.channels.cache.get(key)!.name,
- value: key,
- description: `${stats[key]!.name}`
- }))
- )
- ]
- : [
- selectMenu
- .setPlaceholder("The server has no stats channels")
- .setDisabled(true)
- .setOptions([
- {
- label: "*Placeholder*",
- value: "placeholder",
- description: "No stats channels"
- }
- ])
- ]
- )
- ]
- });
- let i: StringSelectMenuInteraction;
- try {
- i = await m.awaitMessageComponent({
- time: 300000,
- filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
- }) as StringSelectMenuInteraction;
- } catch (e) {
- timedOut = true;
- continue;
+ .setMaxValues(1);
+ for (const [id, { name, enabled }] of Object.entries(stats)) {
+ pageSelect.addOption()
}
- i.deferUpdate();
- if (i.customId === "remove") {
- const toRemove = i.values;
- await client.database.guilds.write(
- interaction.guild!.id,
- null,
- toRemove.map((k) => `stats.${k}`)
- );
- }
- }
- await interaction.editReply({
- embeds: [new Discord.EmbedBuilder(m.embeds[0]!.data).setFooter({ text: "Message timed out" })],
- components: []
- });
+ // [ Action... ] -> Edit, delete, reorder
+ // [Back][Next][Add]
+ } while (!closed);
+ closed = true;
};
const check = (interaction: CommandInteraction) => {
@@ -229,21 +49,7 @@
return true;
};
-const generateStatsChannelAutocomplete = (prompt: string): string[] => {
- return [prompt];
-};
-
-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 };
-export { autocomplete };
\ No newline at end of file
+export { check };
\ No newline at end of file
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 892a420..aa25b69 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -163,7 +163,7 @@
"\nAre you sure you want to apply these settings?"
)
.setColor("Warning")
- .setFailedMessage("Cancelled", "Warning", "GUILD.TICKET.CLOSE") // TODO: Set Actual Message
+ .setFailedMessage("No changes were made", "Success", "GUILD.TICKET.OPEN")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index e7143fb..42376e8 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -103,7 +103,7 @@
.setTitle("Welcome Events")
.setDescription(generateKeyValueList(options))
.setColor("Warning")
- .setFailedMessage("Cancelled", "Warning", "GUILD.ROLES.DELETE") //TODO: Actual Message Needed
+ .setFailedMessage("No changes were made", "Success", "GUILD.ROLES.CREATE")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
@@ -324,7 +324,7 @@
if (beforeLastOpenBracket !== null) {
if (afterLastOpenBracket !== null) {
for (const replacement of validReplacements) {
- if (replacement.startsWith(afterLastOpenBracket[0].slice(1))) {
+ if (replacement.startsWith(afterLastOpenBracket[0]!.slice(1))) {
autocompletions.push(`${beforeLastOpenBracket[1]}{${replacement}}`);
}
}