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