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