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