PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 1 | import { LoadingEmbed } from "../utils/defaults.js"; |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 2 | import Discord, { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 3 | ActionRowBuilder, |
| 4 | ButtonBuilder, |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 5 | MessageComponentInteraction, |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 6 | StringSelectMenuInteraction, |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 7 | Guild, |
| 8 | CommandInteraction, |
| 9 | GuildTextBasedChannel, |
| 10 | Message, |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 11 | ButtonStyle, |
| 12 | ChannelType |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 13 | } from "discord.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 14 | import EmojiEmbed from "../utils/generateEmojiEmbed.js"; |
| 15 | import getEmojiByName from "../utils/getEmojiByName.js"; |
| 16 | import createPageIndicator from "../utils/createPageIndicator.js"; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 17 | import { Embed } from "../utils/defaults.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 18 | |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 19 | export default async (guild: Guild, interaction?: CommandInteraction) => { |
| 20 | let c: GuildTextBasedChannel | null = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 21 | c = c |
| 22 | ? c |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 23 | : (guild.channels.cache.find( |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 24 | (ch) => |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 25 | [ |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 26 | ChannelType.GuildText, |
| 27 | ChannelType.GuildAnnouncement, |
| 28 | ChannelType.PublicThread, |
| 29 | ChannelType.PrivateThread, |
| 30 | ChannelType.AnnouncementThread |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 31 | ].includes(ch.type) && |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 32 | ch.permissionsFor(guild.roles.everyone).has("SendMessages") && |
| 33 | ch.permissionsFor(guild.members.me!).has("EmbedLinks") |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 34 | ) as GuildTextBasedChannel | undefined) ?? null; |
| 35 | if (interaction) c = interaction.channel as GuildTextBasedChannel; |
| 36 | if (!c) { |
| 37 | return; |
| 38 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 39 | const pages = [ |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 40 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 41 | .setEmbed( |
| 42 | new EmojiEmbed() |
| 43 | .setTitle("Welcome to Nucleus") |
| 44 | .setDescription( |
| 45 | "Thanks for adding Nucleus to your server\n\n" + |
| 46 | "On the next few pages you can find instructions on getting started, and commands you may want to set up\n\n" + |
| 47 | "If you need support, have questions or want features, you can let us know in [Clicks](https://discord.gg/bPaNnxe)" |
| 48 | ) |
| 49 | .setEmoji("NUCLEUS.LOGO") |
| 50 | .setStatus("Danger") |
| 51 | ) |
| 52 | .setTitle("Welcome") |
| 53 | .setDescription("About Nucleus") |
| 54 | .setPageId(0), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 55 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 56 | .setEmbed( |
| 57 | new EmojiEmbed() |
| 58 | .setTitle("Logging") |
| 59 | .setDescription( |
| 60 | "Nucleus can log server events and keep you informed with what content is being posted to your server.\n" + |
| 61 | "We have 2 different types of logs, which each can be configured to send to a channel of your choice:\n" + |
| 62 | "**General Logs:** These are events like kicks and channel changes etc.\n" + |
| 63 | "**Warning Logs:** Warnings like NSFW avatars and spam etc. that may require action by a server staff member. " + |
| 64 | "These go to to a separate staff notifications channel.\n\n" + |
| 65 | "A general log channel can be set with `/settings log`\n" + |
| 66 | "A warning log channel can be set with `/settings warnings channel`" |
| 67 | ) |
| 68 | .setEmoji("ICONS.LOGGING") |
| 69 | .setStatus("Danger") |
| 70 | ) |
| 71 | .setTitle("Logging") |
| 72 | .setDescription("Logging, staff warning logs etc.") |
| 73 | .setPageId(1), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 74 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 75 | .setEmbed( |
| 76 | new EmojiEmbed() |
| 77 | .setTitle("Moderation") |
| 78 | .setDescription( |
| 79 | "Nucleus has a number of commands that can be used to moderate your server.\n" + |
| 80 | "These commands are all found under `/mod`, and they include:\n" + |
| 81 | `**${getEmojiByName( |
| 82 | "PUNISH.WARN.YELLOW" |
| 83 | )} Warn:** The user is warned (via DM) that they violated server rules.\n` + |
| 84 | `**${getEmojiByName( |
| 85 | "PUNISH.CLEARHISTORY" |
| 86 | )} Clear:** Some messages from a user are deleted in a channel.\n` + |
| 87 | `**${getEmojiByName( |
| 88 | "PUNISH.MUTE.YELLOW" |
| 89 | )} Mute:** The user is unable to send messages or join voice chats.\n` + |
| 90 | `**${getEmojiByName( |
| 91 | "PUNISH.MUTE.GREEN" |
| 92 | )} Unmute:** The user is able to send messages in the server.\n` + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 93 | `**${getEmojiByName("PUNISH.KICK.RED")} Kick:** The user is removed from the server.\n` + |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 94 | `**${getEmojiByName( |
| 95 | "PUNISH.SOFTBAN" |
| 96 | )} Softban:** Kicks the user, deleting their messages from every channel.\n` + |
| 97 | `**${getEmojiByName( |
| 98 | "PUNISH.BAN.RED" |
| 99 | )} Ban:** The user is removed from the server, and they are unable to rejoin.\n` + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 100 | `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 101 | ) |
| 102 | .setEmoji("PUNISH.BAN.RED") |
| 103 | .setStatus("Danger") |
| 104 | ) |
| 105 | .setTitle("Moderation") |
| 106 | .setDescription("Basic moderation commands") |
| 107 | .setPageId(2), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 108 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 109 | .setEmbed( |
| 110 | new EmojiEmbed() |
| 111 | .setTitle("Verify") |
| 112 | .setDescription( |
| 113 | "Nucleus has a verification system that allows users to prove they aren't bots.\n" + |
| 114 | "This is done by running `/verify` which sends a message only the user can see, giving them a link to a CAPTCHA to verify.\n" + |
| 115 | "After the user complete's the CAPTCHA, they are given a role and can use the permissions accordingly.\n" + |
| 116 | "You can set the role given with `/settings verify`" |
| 117 | ) |
| 118 | .setEmoji("CONTROL.REDTICK") |
| 119 | .setStatus("Danger") |
| 120 | ) |
| 121 | .setTitle("Verify") |
| 122 | .setDescription("Captcha verification system") |
| 123 | .setPageId(3), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 124 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 125 | .setEmbed( |
| 126 | new EmojiEmbed() |
| 127 | .setTitle("Content Scanning") |
| 128 | .setDescription( |
| 129 | "Nucleus has a content scanning system that automatically scans links and images sent by users.\n" + |
| 130 | "Nucleus can detect, delete, and punish users for sending NSFW content, or links to scam or adult sites.\n" + |
| 131 | "You can set the threshold for this in `/settings automation`" // TODO |
| 132 | ) |
| 133 | .setEmoji("MOD.IMAGES.TOOSMALL") |
| 134 | .setStatus("Danger") |
| 135 | ) |
| 136 | .setTitle("Content Scanning") |
| 137 | .setDescription("Content (NSFW, malware, scams) scanning") |
| 138 | .setPageId(4), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 139 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 140 | .setEmbed( |
| 141 | new EmojiEmbed() |
| 142 | .setTitle("Tickets") |
| 143 | .setDescription( |
| 144 | "Nucleus has a ticket system that allows users to create tickets and have a support team respond to them.\n" + |
| 145 | "Tickets can be created with `/ticket create` and a channel is created, pinging the user and support role.\n" + |
| 146 | "When the ticket is resolved, anyone can run `/ticket close` (or click the button) to close it.\n" + |
| 147 | "Running `/ticket close` again will delete the ticket." |
| 148 | ) |
| 149 | .setEmoji("GUILD.TICKET.CLOSE") |
| 150 | .setStatus("Danger") |
| 151 | ) |
| 152 | .setTitle("Tickets") |
| 153 | .setDescription("Ticket system") |
| 154 | .setPageId(5), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 155 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 156 | .setEmbed( |
| 157 | new EmojiEmbed() |
| 158 | .setTitle("Tags") |
| 159 | .setDescription( |
| 160 | "Add a tag system to your server with the `/tag` and `/tags` commands.\n" + |
| 161 | "To create a tag, type `/tags create <tag name> <tag content>`.\n" + |
| 162 | "Tag names and content can be edited with `/tags edit`.\n" + |
| 163 | "To delete a tag, type `/tags delete <tag name>`.\n" + |
| 164 | "To view all tags, type `/tags list`.\n" |
| 165 | ) |
| 166 | .setEmoji("PUNISH.NICKNAME.RED") |
| 167 | .setStatus("Danger") |
| 168 | ) |
| 169 | .setTitle("Tags") |
| 170 | .setDescription("Tag system") |
| 171 | .setPageId(6), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 172 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 173 | .setEmbed( |
| 174 | new EmojiEmbed() |
| 175 | .setTitle("Premium") |
| 176 | .setDescription( |
| 177 | "In the near future, we will be releasing extra premium only features.\n" + |
| 178 | "These features will include:\n\n" + |
| 179 | "**Attachment logs**\n> When a message with attachments is edited or deleted, the logs will also include the images sent.\n" + |
| 180 | "\nPremium is not yet available. Check `/nucleus premium` for updates on features and pricing" |
| 181 | ) |
| 182 | .setEmoji("NUCLEUS.COMMANDS.LOCK") |
| 183 | .setStatus("Danger") |
| 184 | ) |
| 185 | .setTitle("Premium") |
| 186 | .setDescription("Premium features") |
| 187 | .setPageId(7) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 188 | ]; |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 189 | let m: Message; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 190 | if (interaction) { |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 191 | m = (await interaction.reply({ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 192 | embeds: LoadingEmbed, |
| 193 | fetchReply: true, |
| 194 | ephemeral: true |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 195 | })) as Message; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 196 | } else { |
| 197 | m = await c.send({ embeds: LoadingEmbed }); |
| 198 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 199 | let page = 0; |
| 200 | |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 201 | const publicFilter = async (component: MessageComponentInteraction) => { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 202 | return (component.member as Discord.GuildMember).permissions.has("ManageGuild"); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 203 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 204 | |
| 205 | let selectPaneOpen = false; |
| 206 | |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 207 | let cancelled = false; |
| 208 | let timedOut = false; |
| 209 | while (!cancelled && !timedOut) { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 210 | let selectPane: ActionRowBuilder<Discord.StringSelectMenuBuilder | ButtonBuilder>[] = []; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 211 | |
| 212 | if (selectPaneOpen) { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 213 | const options: Discord.StringSelectMenuOptionBuilder[] = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 214 | pages.forEach((embed) => { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 215 | options.push(new Discord.StringSelectMenuOptionBuilder() |
| 216 | .setLabel(embed.title) |
| 217 | .setValue(embed.pageId.toString()) |
| 218 | .setDescription(embed.description || "") |
| 219 | ); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 220 | }); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 221 | selectPane = [ |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 222 | new ActionRowBuilder<Discord.StringSelectMenuBuilder>().addComponents([ |
| 223 | new Discord.StringSelectMenuBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 224 | .addOptions(options) |
| 225 | .setCustomId("page") |
| 226 | .setMaxValues(1) |
| 227 | .setPlaceholder("Choose a page...") |
| 228 | ]) |
| 229 | ]; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 230 | } |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 231 | const components: ActionRowBuilder<ButtonBuilder | Discord.StringSelectMenuBuilder>[] = selectPane.concat([ |
| 232 | new ActionRowBuilder<ButtonBuilder>().addComponents( |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 233 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 234 | .setCustomId("left") |
| 235 | .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 236 | .setStyle(ButtonStyle.Secondary) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 237 | .setDisabled(page === 0), |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 238 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 239 | .setCustomId("select") |
| 240 | .setEmoji(getEmojiByName("CONTROL.MENU", "id")) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 241 | .setStyle(selectPaneOpen ? ButtonStyle.Primary : ButtonStyle.Secondary) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 242 | .setDisabled(false), |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 243 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 244 | .setCustomId("right") |
| 245 | .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 246 | .setStyle(ButtonStyle.Secondary) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 247 | .setDisabled(page === pages.length - 1) |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 248 | ) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 249 | ]); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 250 | if (interaction) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 251 | const em = new Discord.EmbedBuilder(pages[page]!.embed); |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 252 | em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page)); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 253 | await interaction.editReply({ |
| 254 | embeds: [em], |
| 255 | components: components |
| 256 | }); |
| 257 | } else { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 258 | const em = new Discord.EmbedBuilder(pages[page]!.embed); |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 259 | em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page)); |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 260 | (await m.edit({ |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 261 | embeds: [em], |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 262 | components: components |
| 263 | })) as Message; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 264 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 265 | let i; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 266 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 267 | i = await m.awaitMessageComponent({ |
| 268 | filter: interaction |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 269 | ? (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id } |
| 270 | : publicFilter, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 271 | time: 300000 |
| 272 | }); |
| 273 | } catch (e) { |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 274 | timedOut = true; |
| 275 | continue; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 276 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 277 | i.deferUpdate(); |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 278 | if (!("customId" in i.component)) { |
| 279 | continue; |
| 280 | } else if (i.component.customId === "left") { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 281 | if (page > 0) page--; |
| 282 | selectPaneOpen = false; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 283 | } else if (i.component.customId === "right") { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 284 | if (page < pages.length - 1) page++; |
| 285 | selectPaneOpen = false; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 286 | } else if (i.component.customId === "select") { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 287 | selectPaneOpen = !selectPaneOpen; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 288 | } else if (i.component.customId === "page") { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 289 | page = parseInt((i as StringSelectMenuInteraction).values[0]!); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 290 | selectPaneOpen = false; |
| 291 | } else { |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 292 | cancelled = true; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 293 | } |
| 294 | } |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 295 | if (timedOut) { |
| 296 | if (interaction) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 297 | const em = new Discord.EmbedBuilder(pages[page]!.embed); |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 298 | em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({ |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 299 | text: "Message timed out" |
| 300 | }); |
| 301 | await interaction.editReply({ |
| 302 | embeds: [em], |
| 303 | components: [] |
| 304 | }); |
| 305 | } else { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 306 | const em = new Discord.EmbedBuilder(pages[page]!.embed); |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 307 | em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({ |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 308 | text: "Message timed out" |
| 309 | }); |
| 310 | await m.edit({ |
| 311 | embeds: [em], |
| 312 | components: [] |
| 313 | }); |
| 314 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 315 | } else { |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 316 | if (interaction) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 317 | const em = new Discord.EmbedBuilder(pages[page]!.embed); |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame^] | 318 | em.setDescription(em.data.description + "\n\n" + createPageIndicator(pages.length, page)); |
Skyler Grey | f21323a | 2022-08-13 23:58:22 +0100 | [diff] [blame] | 319 | em.setFooter({ text: "Message closed" }); |
| 320 | interaction.editReply({ |
| 321 | embeds: [em], |
| 322 | components: [] |
| 323 | }); |
| 324 | } else { |
| 325 | m.delete(); |
| 326 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 327 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 328 | }; |