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