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