pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 1 | import { LoadingEmbed } from "./../../utils/defaultEmbeds.js"; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 2 | import Discord, { |
| 3 | CommandInteraction, |
| 4 | GuildMember, |
| 5 | Message, |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 6 | ActionRowBuilder, |
| 7 | Component, |
| 8 | ButtonBuilder, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 9 | MessageComponentInteraction, |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 10 | ButtonStyle |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 11 | } from "discord.js"; |
PineaFan | 100df68 | 2023-01-02 13:26:08 +0000 | [diff] [blame] | 12 | import type { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 13 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 14 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
| 15 | import generateKeyValueList from "../../utils/generateKeyValueList.js"; |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 16 | import createPageIndicator from "../../utils/createPageIndicator.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 17 | import client from "../../utils/client.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 18 | |
| 19 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 20 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 21 | .setName("about") |
| 22 | .setDescription("Shows info about a user") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 23 | .addUserOption((option) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 24 | option.setName("user").setDescription("The user to get info about | Default: Yourself") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 25 | ); |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 26 | |
| 27 | class Embed { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 28 | embed: Discord.EmbedBuilder; |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 29 | title: string; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | description = ""; |
| 31 | pageId = 0; |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 32 | setEmbed(embed: Discord.EmbedBuilder) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 33 | this.embed = embed; |
| 34 | return this; |
| 35 | } |
| 36 | setTitle(title: string) { |
| 37 | this.title = title; |
| 38 | return this; |
| 39 | } |
| 40 | setDescription(description: string) { |
| 41 | this.description = description; |
| 42 | return this; |
| 43 | } |
| 44 | setPageId(pageId: number) { |
| 45 | this.pageId = pageId; |
| 46 | return this; |
| 47 | } |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 50 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 51 | if (!interaction.guild) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 52 | const { renderUser, renderDelta } = client.logger; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 53 | const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 54 | const flags: string[] = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 55 | if ( |
| 56 | [ |
| 57 | "438733159748599813", // Pinea |
| 58 | "317731855317336067", // Mini |
| 59 | "261900651230003201", // Coded |
| 60 | "511655498676699136" // Zan |
| 61 | ].includes(member.user.id) |
| 62 | ) { |
| 63 | flags.push("NUCLEUSDEVELOPER"); |
| 64 | } |
| 65 | if ( |
| 66 | (await client.guilds.cache.get("684492926528651336")?.members.fetch()) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 67 | ?.filter((m: GuildMember) => m.roles.cache.has("760896837866749972")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 68 | ?.map((m: GuildMember) => m.id) |
| 69 | .includes(member.user.id) |
| 70 | ) { |
| 71 | flags.push("CLICKSDEVELOPER"); |
| 72 | } |
| 73 | member.user.flags.toArray().map((flag) => { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 74 | flags.push(flag.toString()); |
| 75 | }); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 76 | if (member.user.bot) { |
| 77 | flags.push("BOT"); |
| 78 | } |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 79 | // Check if they are boosting the server |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 80 | if (member.premiumSince) { |
| 81 | flags.push("BOOSTER"); |
| 82 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 83 | const nameReplacements = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 84 | NUCLEUSDEVELOPER: "**Nucleus Developer**", |
| 85 | CLICKSDEVELOPER: "Clicks Developer", |
| 86 | HOUSE_BRAVERY: "Hypesquad Bravery", |
| 87 | HOUSE_BRILLIANCE: "Hypesquad Brilliance", |
| 88 | HOUSE_BALANCE: "Hypesquad Balance", |
| 89 | HYPESQUAD_EVENTS: "Hypesquad Events", |
| 90 | EARLY_SUPPORTER: "Early Supporter", |
| 91 | BUGHUNTER_LEVEL_1: "Bug Hunter Level 1", |
| 92 | BUGHUNTER_LEVEL_2: "Bug Hunter Level 2", |
| 93 | PARTNERED_SERVER_OWNER: "Partnered Server Owner", |
| 94 | DISCORD_EMPLOYEE: "Discord Staff", |
| 95 | EARLY_VERIFIED_BOT_DEVELOPER: "Verified Bot Developer", |
| 96 | BOT: "Bot", |
| 97 | BOOSTER: "Server Booster" |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 98 | }; |
| 99 | const members = await interaction.guild.members.fetch(); |
| 100 | const membersArray = [...members.values()]; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 101 | membersArray.sort((a, b) => { |
| 102 | if (a.joinedTimestamp === null) return 1; |
| 103 | if (b.joinedTimestamp === null) return -1; |
| 104 | return a.joinedTimestamp - b.joinedTimestamp; |
| 105 | }); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 106 | const joinPos = membersArray.findIndex((m) => m.id === member.user.id); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 107 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 108 | const roles = member.roles.cache.filter((r) => r.id !== interaction.guild!.id).sort(); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 109 | let s = ""; |
| 110 | let count = 0; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 111 | let ended = false; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 112 | for (const roleId in roles) { |
| 113 | const string = `<@&${roleId}>, `; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 114 | if (s.length + string.length > 1000) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 115 | ended = true; |
| 116 | s += `and ${roles.size - count} more`; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 117 | break; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 118 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 119 | count++; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 120 | s += string; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 121 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 122 | if (s.length > 0 && !ended) s = s.slice(0, -2); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 123 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 124 | let perms = ""; |
| 125 | const permsArray = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 126 | ADMINISTRATOR: "Administrator", |
| 127 | MANAGE_GUILD: "Manage Server", |
| 128 | MANAGE_ROLES: "Manage Roles", |
| 129 | MANAGE_CHANNELS: "Manage Channels", |
| 130 | KICK_MEMBERS: "Kick Members", |
| 131 | BAN_MEMBERS: "Ban Members", |
| 132 | MODERATE_MEMBERS: "Moderate Members", |
| 133 | MANAGE_NICKNAMES: "Manage Nicknames", |
| 134 | MANAGE_WEBHOOKS: "Manage Webhooks", |
| 135 | MANAGE_MESSAGES: "Manage Messages", |
| 136 | VIEW_AUDIT_LOG: "View Audit Log", |
| 137 | MENTION_EVERYONE: "Mention Everyone" |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 138 | }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 139 | Object.keys(permsArray).map((perm) => { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 140 | const hasPerm = member.permissions.has(perm as Discord.PermissionString); |
| 141 | perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 142 | }); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 143 | |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 144 | let selectPaneOpen = false; |
| 145 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 146 | const embeds = [ |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 147 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 148 | .setEmbed( |
| 149 | new EmojiEmbed() |
| 150 | .setTitle("User Info: General") |
| 151 | .setStatus("Success") |
| 152 | .setEmoji("MEMBER.JOIN") |
| 153 | .setDescription( |
| 154 | flags |
| 155 | .map((flag) => { |
| 156 | if (nameReplacements[flag]) { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 157 | return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag]; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 158 | } |
| 159 | }) |
| 160 | .join("\n") + |
| 161 | "\n\n" + |
| 162 | generateKeyValueList({ |
| 163 | member: renderUser(member.user), |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 164 | nickname: member.nickname ?? "*None set*", |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 165 | id: `\`${member.id}\``, |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 166 | "joined the server": renderDelta(member.joinedTimestamp), |
| 167 | "joined discord": renderDelta(member.user.createdTimestamp), |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 168 | "boost status": member.premiumSince |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 169 | ? `Started boosting ${renderDelta(member.premiumSinceTimestamp)}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 170 | : "*Not boosting*", |
| 171 | "join position": `${joinPos + 1}` |
| 172 | }) |
| 173 | ) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 174 | .setThumbnail(member.user.displayAvatarURL({ dynamic: true })) |
| 175 | .setImage((await member.user.fetch()).bannerURL({ format: "gif" })) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 176 | ) |
| 177 | .setTitle("General") |
| 178 | .setDescription("General information about the user") |
| 179 | .setPageId(0), |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 180 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 181 | .setEmbed( |
| 182 | new EmojiEmbed() |
| 183 | .setTitle("User Info: Roles") |
| 184 | .setStatus("Success") |
| 185 | .setEmoji("GUILD.ROLES.CREATE") |
| 186 | .setDescription( |
| 187 | generateKeyValueList({ |
| 188 | member: renderUser(member.user), |
| 189 | id: `\`${member.id}\``, |
| 190 | roles: `${member.roles.cache.size - 1}` |
| 191 | }) + |
| 192 | "\n" + |
| 193 | (s.length > 0 ? s : "*None*") + |
| 194 | "\n" |
| 195 | ) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 196 | .setThumbnail(member.user.displayAvatarURL({ dynamic: true })) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 197 | ) |
| 198 | .setTitle("Roles") |
| 199 | .setDescription("Roles the user has") |
| 200 | .setPageId(1), |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 201 | new Embed() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 202 | .setEmbed( |
| 203 | new EmojiEmbed() |
| 204 | .setTitle("User Info: Key Permissions") |
| 205 | .setStatus("Success") |
| 206 | .setEmoji("GUILD.ROLES.CREATE") |
| 207 | .setDescription( |
| 208 | generateKeyValueList({ |
| 209 | member: renderUser(member.user), |
| 210 | id: `\`${member.id}\`` |
| 211 | }) + |
| 212 | "\n" + |
| 213 | perms |
| 214 | ) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 215 | .setThumbnail(member.user.displayAvatarURL({ dynamic: true })) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 216 | ) |
| 217 | .setTitle("Key Permissions") |
| 218 | .setDescription("Key permissions the user has") |
| 219 | .setPageId(2) |
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 | const m = (await interaction.reply({ |
| 222 | embeds: LoadingEmbed, |
| 223 | fetchReply: true, |
| 224 | ephemeral: true |
| 225 | })) as Message; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 226 | let page = 0; |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 227 | let timedOut = false; |
| 228 | while (!timedOut) { |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 229 | const em = new Discord.EmbedBuilder(embeds[page].embed); |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 230 | em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page)); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 231 | let selectPane = []; |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 232 | |
| 233 | if (selectPaneOpen) { |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 234 | const options: MessageSelectOptionData[] = []; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 235 | embeds.forEach((embed) => { |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 236 | options.push({ |
| 237 | label: embed.title, |
| 238 | value: embed.pageId.toString(), |
| 239 | description: embed.description || "" |
| 240 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 241 | }); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 242 | selectPane = [ |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 243 | new ActionRowBuilder().addComponents([ |
| 244 | new Discord.SelectMenuBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 245 | .addOptions(options) |
| 246 | .setCustomId("page") |
| 247 | .setMaxValues(1) |
| 248 | .setPlaceholder("Choose a page...") |
| 249 | ]) |
| 250 | ]; |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 251 | } |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 252 | await interaction.editReply({ |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 253 | embeds: [em], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 254 | components: selectPane.concat([ |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 255 | new ActionRowBuilder().addComponents([ |
| 256 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 257 | .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 258 | .setStyle(ButtonStyle.Secondary) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 259 | .setCustomId("left") |
| 260 | .setDisabled(page === 0), |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 261 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 262 | .setEmoji(getEmojiByName("CONTROL.MENU", "id")) |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 263 | .setStyle(selectPaneOpen ? ButtonStyle.Primary : ButtonStyle.Secondary) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 264 | .setCustomId("select") |
| 265 | .setDisabled(false), |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 266 | new ButtonBuilder() |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 267 | .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) |
| 268 | .setCustomId("right") |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 269 | .setStyle(ButtonStyle.Secondary) |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 270 | .setDisabled(page === embeds.length - 1) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 271 | ]) |
| 272 | ]) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 273 | }); |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 274 | let i: MessageComponentInteraction; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 275 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 276 | i = await m.awaitMessageComponent({ time: 300000 }); |
| 277 | } catch { |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 278 | timedOut = true; |
| 279 | continue; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 280 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 281 | i.deferUpdate(); |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 282 | if ((i.component as Component).customId === "left") { |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 283 | if (page > 0) page--; |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 284 | selectPaneOpen = false; |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 285 | } else if ((i.component as Component).customId === "right") { |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 286 | if (page < embeds.length - 1) page++; |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 287 | selectPaneOpen = false; |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 288 | } else if ((i.component as Component).customId === "select") { |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 289 | selectPaneOpen = !selectPaneOpen; |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 290 | } else if ((i.component as Component).customId === "page") { |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 291 | page = parseInt((i as SelectMenuInteraction).values[0]); |
pineafan | ea06304 | 2022-05-19 19:08:44 +0100 | [diff] [blame] | 292 | selectPaneOpen = false; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 293 | } |
| 294 | } |
TheCodedProf | 21c0859 | 2022-09-13 14:14:43 -0400 | [diff] [blame] | 295 | const em = new Discord.EmbedBuilder(embeds[page].embed); |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 296 | em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | Message closed"); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 297 | await interaction.editReply({ |
| 298 | embeds: [em], |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 299 | components: [] |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 300 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 301 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 302 | |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 303 | const check = () => { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 304 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 305 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 306 | |
| 307 | export { command }; |
| 308 | export { callback }; |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 309 | export { check }; |