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 | Message, |
| 5 | MessageActionRow, |
| 6 | MessageActionRowComponent, |
| 7 | MessageButton, |
| 8 | MessageComponentInteraction, |
| 9 | MessageEmbed, |
| 10 | MessageSelectMenu, |
| 11 | Role, |
| 12 | SelectMenuInteraction, |
| 13 | TextInputComponent |
| 14 | } from "discord.js"; |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 15 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| 16 | import confirmationMessage from "../../utils/confirmationMessage.js"; |
| 17 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 18 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 19 | import client from "../../utils/client.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 20 | import { modalInteractionCollector } from "../../utils/dualCollector.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 21 | |
| 22 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 23 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 24 | .setName("verify") |
| 25 | .setDescription("Manage the role given after typing /verify") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 26 | .addRoleOption((option) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 27 | option.setName("role").setDescription("The role to give after verifying").setRequired(false) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 28 | ); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 29 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 30 | const callback = async (interaction: CommandInteraction): Promise<void | unknown> => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 31 | const m = (await interaction.reply({ |
| 32 | embeds: LoadingEmbed, |
| 33 | ephemeral: true, |
| 34 | fetchReply: true |
| 35 | })) as Message; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 36 | if (interaction.options.getRole("role")) { |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 37 | let role: Role; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 38 | try { |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 39 | role = interaction.options.getRole("role") as Role; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 40 | } catch { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 41 | return await interaction.editReply({ |
| 42 | embeds: [ |
| 43 | new EmojiEmbed() |
| 44 | .setEmoji("GUILD.ROLES.DELETE") |
| 45 | .setTitle("Verify Role") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 46 | .setDescription("The role you provided is not a valid role") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 47 | .setStatus("Danger") |
| 48 | ] |
| 49 | }); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 50 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 51 | role = role as Discord.Role; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 52 | if (role.guild.id !== interaction.guild.id) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 53 | return interaction.editReply({ |
| 54 | embeds: [ |
| 55 | new EmojiEmbed() |
| 56 | .setTitle("Verify Role") |
| 57 | .setDescription("You must choose a role in this server") |
| 58 | .setStatus("Danger") |
| 59 | .setEmoji("GUILD.ROLES.DELETE") |
| 60 | ] |
| 61 | }); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 62 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 63 | const confirmation = await new confirmationMessage(interaction) |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 64 | .setEmoji("GUILD.ROLES.EDIT") |
| 65 | .setTitle("Verify Role") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 66 | .setDescription(`Are you sure you want to set the verify role to <@&${role.id}>?`) |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 67 | .setColor("Warning") |
| 68 | .setInverted(true) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 69 | .send(true); |
| 70 | if (confirmation.cancelled) return; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 71 | if (confirmation.success) { |
| 72 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 73 | await client.database.guilds.write(interaction.guild.id, { |
| 74 | "verify.role": role.id, |
| 75 | "verify.enabled": true |
| 76 | }); |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 77 | const { log, NucleusColors, entry, renderUser, renderRole } = client.logger; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 78 | const data = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 79 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 80 | type: "verifyRoleChanged", |
| 81 | displayName: "Verify Role Changed", |
| 82 | calculateType: "nucleusSettingsUpdated", |
| 83 | color: NucleusColors.green, |
| 84 | emoji: "CONTROL.BLOCKTICK", |
| 85 | timestamp: new Date().getTime() |
| 86 | }, |
| 87 | list: { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 88 | memberId: entry(interaction.user.id, `\`${interaction.user.id}\``), |
| 89 | changedBy: entry(interaction.user.id, renderUser(interaction.user)), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 90 | role: entry(role.id, renderRole(role)) |
| 91 | }, |
| 92 | hidden: { |
| 93 | guild: interaction.guild.id |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 94 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 95 | }; |
| 96 | log(data); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 97 | } catch (e) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 98 | console.log(e); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 99 | return interaction.editReply({ |
| 100 | embeds: [ |
| 101 | new EmojiEmbed() |
| 102 | .setTitle("Verify Role") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 103 | .setDescription("Something went wrong while setting the verify role") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 104 | .setStatus("Danger") |
| 105 | .setEmoji("GUILD.ROLES.DELETE") |
| 106 | ], |
| 107 | components: [] |
| 108 | }); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 109 | } |
| 110 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 111 | return interaction.editReply({ |
| 112 | embeds: [ |
| 113 | new EmojiEmbed() |
| 114 | .setTitle("Verify Role") |
| 115 | .setDescription("No changes were made") |
| 116 | .setStatus("Success") |
| 117 | .setEmoji("GUILD.ROLES.CREATE") |
| 118 | ], |
| 119 | components: [] |
| 120 | }); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | let clicks = 0; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 124 | const data = await client.database.guilds.read(interaction.guild.id); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 125 | let role = data.verify.role; |
| 126 | while (true) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 127 | await interaction.editReply({ |
| 128 | embeds: [ |
| 129 | new EmojiEmbed() |
| 130 | .setTitle("Verify Role") |
| 131 | .setDescription( |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 132 | role ? `Your verify role is currently set to <@&${role}>` : "You have not set a verify role" |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 133 | ) |
| 134 | .setStatus("Success") |
| 135 | .setEmoji("GUILD.ROLES.CREATE") |
| 136 | ], |
| 137 | components: [ |
| 138 | new MessageActionRow().addComponents([ |
| 139 | new MessageButton() |
| 140 | .setCustomId("clear") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 141 | .setLabel(clicks ? "Click again to confirm" : "Reset role") |
| 142 | .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 143 | .setStyle("DANGER") |
| 144 | .setDisabled(!role), |
| 145 | new MessageButton() |
| 146 | .setCustomId("send") |
| 147 | .setLabel("Add verify button") |
| 148 | .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id")) |
| 149 | .setStyle("PRIMARY") |
| 150 | ]) |
| 151 | ] |
| 152 | }); |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 153 | let i: MessageComponentInteraction; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 154 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 155 | i = await m.awaitMessageComponent({ time: 300000 }); |
| 156 | } catch (e) { |
| 157 | break; |
| 158 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 159 | i.deferUpdate(); |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 160 | if ((i.component as MessageActionRowComponent).customId === "clear") { |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 161 | clicks += 1; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 162 | if (clicks === 2) { |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 163 | clicks = 0; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 164 | await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 165 | role = undefined; |
| 166 | } |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 167 | } else if ((i.component as MessageActionRowComponent).customId === "send") { |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 168 | const verifyMessages = [ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 169 | { |
| 170 | label: "Verify", |
| 171 | description: "Click the button below to get verified" |
| 172 | }, |
| 173 | { |
| 174 | label: "Get verified", |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 175 | description: "To get access to the rest of the server, click the button below" |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 176 | }, |
| 177 | { |
| 178 | label: "Ready to verify?", |
| 179 | description: "Click the button below to verify yourself" |
| 180 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 181 | ]; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 182 | while (true) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 183 | await interaction.editReply({ |
| 184 | embeds: [ |
| 185 | new EmojiEmbed() |
| 186 | .setTitle("Verify Button") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 187 | .setDescription("Select a message template to send in this channel") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 188 | .setFooter({ |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 189 | text: role ? "" : "You do no have a verify role set so the button will not work." |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 190 | }) |
| 191 | .setStatus(role ? "Success" : "Warning") |
| 192 | .setEmoji("GUILD.ROLES.CREATE") |
| 193 | ], |
| 194 | components: [ |
| 195 | new MessageActionRow().addComponents([ |
| 196 | new MessageSelectMenu() |
| 197 | .setOptions( |
| 198 | verifyMessages.map( |
| 199 | ( |
| 200 | t: { |
| 201 | label: string; |
| 202 | description: string; |
| 203 | value?: string; |
| 204 | }, |
| 205 | index |
| 206 | ) => { |
| 207 | t.value = index.toString(); |
| 208 | return t as { |
| 209 | value: string; |
| 210 | label: string; |
| 211 | description: string; |
| 212 | }; |
| 213 | } |
| 214 | ) |
| 215 | ) |
| 216 | .setCustomId("template") |
| 217 | .setMaxValues(1) |
| 218 | .setMinValues(1) |
| 219 | .setPlaceholder("Select a message template") |
| 220 | ]), |
| 221 | new MessageActionRow().addComponents([ |
| 222 | new MessageButton() |
| 223 | .setCustomId("back") |
| 224 | .setLabel("Back") |
| 225 | .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
| 226 | .setStyle("DANGER"), |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 227 | new MessageButton().setCustomId("blank").setLabel("Empty").setStyle("SECONDARY"), |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 228 | new MessageButton() |
| 229 | .setCustomId("custom") |
| 230 | .setLabel("Custom") |
| 231 | .setEmoji(getEmojiByName("TICKETS.OTHER", "id")) |
| 232 | .setStyle("PRIMARY") |
| 233 | ]) |
| 234 | ] |
| 235 | }); |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 236 | let i: MessageComponentInteraction; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 237 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 238 | i = await m.awaitMessageComponent({ time: 300000 }); |
| 239 | } catch (e) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 240 | break; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 241 | } |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 242 | if ((i.component as MessageActionRowComponent).customId === "template") { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 243 | i.deferUpdate(); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 244 | await interaction.channel.send({ |
| 245 | embeds: [ |
| 246 | new EmojiEmbed() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 247 | .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 248 | .setDescription( |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 249 | verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 250 | ) |
| 251 | .setStatus("Success") |
| 252 | .setEmoji("CONTROL.BLOCKTICK") |
| 253 | ], |
| 254 | components: [ |
| 255 | new MessageActionRow().addComponents([ |
| 256 | new MessageButton() |
| 257 | .setLabel("Verify") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 258 | .setEmoji(getEmojiByName("CONTROL.TICK", "id")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 259 | .setStyle("SUCCESS") |
| 260 | .setCustomId("verifybutton") |
| 261 | ]) |
| 262 | ] |
| 263 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 264 | break; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 265 | } else if ((i.component as MessageActionRowComponent).customId === "blank") { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 266 | i.deferUpdate(); |
| 267 | await interaction.channel.send({ |
| 268 | components: [ |
| 269 | new MessageActionRow().addComponents([ |
| 270 | new MessageButton() |
| 271 | .setLabel("Verify") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 272 | .setEmoji(getEmojiByName("CONTROL.TICK", "id")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 273 | .setStyle("SUCCESS") |
| 274 | .setCustomId("verifybutton") |
| 275 | ]) |
| 276 | ] |
| 277 | }); |
| 278 | break; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 279 | } else if ((i.component as MessageActionRowComponent).customId === "custom") { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 280 | await i.showModal( |
| 281 | new Discord.Modal() |
| 282 | .setCustomId("modal") |
| 283 | .setTitle("Enter embed details") |
| 284 | .addComponents( |
| 285 | new MessageActionRow<TextInputComponent>().addComponents( |
| 286 | new TextInputComponent() |
| 287 | .setCustomId("title") |
| 288 | .setLabel("Title") |
| 289 | .setMaxLength(256) |
| 290 | .setRequired(true) |
| 291 | .setStyle("SHORT") |
| 292 | ), |
| 293 | new MessageActionRow<TextInputComponent>().addComponents( |
| 294 | new TextInputComponent() |
| 295 | .setCustomId("description") |
| 296 | .setLabel("Description") |
| 297 | .setMaxLength(4000) |
| 298 | .setRequired(true) |
| 299 | .setStyle("PARAGRAPH") |
| 300 | ) |
| 301 | ) |
| 302 | ); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 303 | await interaction.editReply({ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 304 | embeds: [ |
| 305 | new EmojiEmbed() |
| 306 | .setTitle("Verify Button") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 307 | .setDescription("Modal opened. If you can't see it, click back and try again.") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 308 | .setStatus("Success") |
| 309 | .setEmoji("GUILD.TICKET.OPEN") |
| 310 | ], |
| 311 | components: [ |
| 312 | new MessageActionRow().addComponents([ |
| 313 | new MessageButton() |
| 314 | .setLabel("Back") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 315 | .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 316 | .setStyle("PRIMARY") |
| 317 | .setCustomId("back") |
| 318 | ]) |
| 319 | ] |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 320 | }); |
| 321 | let out; |
| 322 | try { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 323 | out = await modalInteractionCollector( |
| 324 | m, |
| 325 | (m) => m.channel.id === interaction.channel.id, |
| 326 | (m) => m.customId === "modify" |
| 327 | ); |
| 328 | } catch (e) { |
| 329 | break; |
| 330 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 331 | if (out.fields) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 332 | const title = out.fields.getTextInputValue("title"); |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 333 | const description = out.fields.getTextInputValue("description"); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 334 | await interaction.channel.send({ |
| 335 | embeds: [ |
| 336 | new EmojiEmbed() |
| 337 | .setTitle(title) |
| 338 | .setDescription(description) |
| 339 | .setStatus("Success") |
| 340 | .setEmoji("CONTROL.BLOCKTICK") |
| 341 | ], |
| 342 | components: [ |
| 343 | new MessageActionRow().addComponents([ |
| 344 | new MessageButton() |
| 345 | .setLabel("Verify") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 346 | .setEmoji(getEmojiByName("CONTROL.TICK", "id")) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 347 | .setStyle("SUCCESS") |
| 348 | .setCustomId("verifybutton") |
| 349 | ]) |
| 350 | ] |
| 351 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 352 | break; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 353 | } else { |
| 354 | continue; |
| 355 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 356 | } |
| 357 | } |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 358 | } else { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 359 | i.deferUpdate(); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 360 | break; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 361 | } |
| 362 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 363 | await interaction.editReply({ |
| 364 | embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })], |
| 365 | components: [] |
| 366 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 367 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 368 | |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 369 | const check = (interaction: CommandInteraction) => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 370 | const member = interaction.member as Discord.GuildMember; |
| 371 | if (!member.permissions.has("MANAGE_GUILD")) |
| 372 | throw "You must have the *Manage Server* permission to use this command"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 373 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 374 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 375 | |
| 376 | export { command }; |
| 377 | export { callback }; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 378 | export { check }; |