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 | Channel, |
| 4 | CommandInteraction, |
| 5 | Message, |
| 6 | MessageActionRow, |
| 7 | MessageButton, |
| 8 | MessageComponentInteraction, |
| 9 | Role |
| 10 | } from "discord.js"; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 11 | import type { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 12 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 13 | import client from "../../utils/client.js"; |
| 14 | import confirmationMessage from "../../utils/confirmationMessage.js"; |
| 15 | import generateKeyValueList from "../../utils/generateKeyValueList.js"; |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 16 | import { ChannelType } from "discord-api-types/v9"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 17 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 18 | |
| 19 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 20 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 21 | .setName("welcome") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 22 | .setDescription("Messages and roles sent or given when someone joins the server") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 23 | .addStringOption((option) => |
| 24 | option |
| 25 | .setName("message") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 26 | .setDescription("The message to send when someone joins the server") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 27 | .setAutocomplete(true) |
| 28 | ) |
| 29 | .addRoleOption((option) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 30 | option.setName("role").setDescription("The role given when someone joins the server") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 31 | ) |
| 32 | .addRoleOption((option) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 33 | option.setName("ping").setDescription("The role pinged when someone joins the server") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 34 | ) |
| 35 | .addChannelOption((option) => |
| 36 | option |
| 37 | .setName("channel") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 38 | .setDescription("The channel the welcome message should be sent to") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 39 | .addChannelTypes([ChannelType.GuildText, ChannelType.GuildNews]) |
| 40 | ); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 41 | |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 42 | const callback = async (interaction: CommandInteraction): Promise<unknown> => { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 43 | const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 44 | await interaction.reply({ |
| 45 | embeds: LoadingEmbed, |
| 46 | fetchReply: true, |
| 47 | ephemeral: true |
| 48 | }); |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 49 | let m: Message; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 50 | if ( |
| 51 | interaction.options.getRole("role") || |
| 52 | interaction.options.getChannel("channel") || |
| 53 | interaction.options.getString("message") |
| 54 | ) { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 55 | let role: Role | null; |
| 56 | let ping: Role | null; |
| 57 | let channel: Channel | null; |
| 58 | const message: string | null = interaction.options.getString("message"); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 59 | try { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 60 | role = interaction.options.getRole("role") as Role | null; |
| 61 | ping = interaction.options.getRole("ping") as Role | null; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 62 | } catch { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 63 | return await interaction.editReply({ |
| 64 | embeds: [ |
| 65 | new EmojiEmbed() |
| 66 | .setEmoji("GUILD.ROLES.DELETE") |
| 67 | .setTitle("Welcome Events") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 68 | .setDescription("The role you provided is not a valid role") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 69 | .setStatus("Danger") |
| 70 | ] |
| 71 | }); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 72 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 73 | try { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 74 | channel = interaction.options.getChannel("channel") as Channel | null; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 75 | } catch { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 76 | return await interaction.editReply({ |
| 77 | embeds: [ |
| 78 | new EmojiEmbed() |
| 79 | .setEmoji("GUILD.ROLES.DELETE") |
| 80 | .setTitle("Welcome Events") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 81 | .setDescription("The channel you provided is not a valid channel") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 82 | .setStatus("Danger") |
| 83 | ] |
| 84 | }); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 85 | } |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 86 | const options: { |
| 87 | role?: string; |
| 88 | ping?: string; |
| 89 | channel?: string; |
| 90 | message?: string; |
| 91 | } = {}; |
| 92 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 93 | if (role) options.role = renderRole(role); |
| 94 | if (ping) options.ping = renderRole(ping); |
| 95 | if (channel) options.channel = renderChannel(channel); |
| 96 | if (message) options.message = "\n> " + message; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 97 | const confirmation = await new confirmationMessage(interaction) |
pineafan | 62ce192 | 2022-08-25 20:34:45 +0100 | [diff] [blame^] | 98 | .setEmoji("GUILD.ROLES.EDIT", "GUILD.ROLES.DELETE") |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 99 | .setTitle("Welcome Events") |
| 100 | .setDescription(generateKeyValueList(options)) |
| 101 | .setColor("Warning") |
| 102 | .setInverted(true) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 103 | .send(true); |
| 104 | if (confirmation.cancelled) return; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 105 | if (confirmation.success) { |
| 106 | try { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 107 | const toChange: { |
| 108 | "welcome.role"?: string; |
| 109 | "welcome.ping"?: string; |
| 110 | "welcome.channel"?: string; |
| 111 | "welcome.message"?: string; |
| 112 | } = {}; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 113 | if (role) toChange["welcome.role"] = role.id; |
| 114 | if (ping) toChange["welcome.ping"] = ping.id; |
| 115 | if (channel) toChange["welcome.channel"] = channel.id; |
| 116 | if (message) toChange["welcome.message"] = message; |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 117 | await client.database.guilds.write(interaction.guild!.id, toChange); |
| 118 | const list: { |
| 119 | memberId: ReturnType<typeof entry>; |
| 120 | changedBy: ReturnType<typeof entry>; |
| 121 | role?: ReturnType<typeof entry>; |
| 122 | ping?: ReturnType<typeof entry>; |
| 123 | channel?: ReturnType<typeof entry>; |
| 124 | message?: ReturnType<typeof entry>; |
| 125 | } = { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 126 | memberId: entry(interaction.user.id, `\`${interaction.user.id}\``), |
| 127 | changedBy: entry(interaction.user.id, renderUser(interaction.user)) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 128 | }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 129 | if (role) list.role = entry(role.id, renderRole(role)); |
| 130 | if (ping) list.ping = entry(ping.id, renderRole(ping)); |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 131 | if (channel) list.channel = entry(channel.id, renderChannel(channel.id)); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 132 | if (message) list.message = entry(message, `\`${message}\``); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 133 | const data = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 134 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 135 | type: "welcomeSettingsUpdated", |
| 136 | displayName: "Welcome Settings Changed", |
| 137 | calculateType: "nucleusSettingsUpdated", |
| 138 | color: NucleusColors.green, |
| 139 | emoji: "CONTROL.BLOCKTICK", |
| 140 | timestamp: new Date().getTime() |
| 141 | }, |
| 142 | list: list, |
| 143 | hidden: { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 144 | guild: interaction.guild!.id |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 145 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 146 | }; |
| 147 | log(data); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 148 | } catch (e) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 149 | console.log(e); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 150 | return interaction.editReply({ |
| 151 | embeds: [ |
| 152 | new EmojiEmbed() |
| 153 | .setTitle("Welcome Events") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 154 | .setDescription("Something went wrong while updating welcome settings") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 155 | .setStatus("Danger") |
| 156 | .setEmoji("GUILD.ROLES.DELETE") |
| 157 | ], |
| 158 | components: [] |
| 159 | }); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 160 | } |
| 161 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 162 | return interaction.editReply({ |
| 163 | embeds: [ |
| 164 | new EmojiEmbed() |
| 165 | .setTitle("Welcome Events") |
| 166 | .setDescription("No changes were made") |
| 167 | .setStatus("Success") |
| 168 | .setEmoji("GUILD.ROLES.CREATE") |
| 169 | ], |
| 170 | components: [] |
| 171 | }); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 172 | } |
| 173 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 174 | let lastClicked = null; |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 175 | let timedOut = false; |
| 176 | do { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 177 | const config = await client.database.guilds.read(interaction.guild!.id); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 178 | m = (await interaction.editReply({ |
| 179 | embeds: [ |
| 180 | new EmojiEmbed() |
| 181 | .setTitle("Welcome Events") |
| 182 | .setDescription( |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 183 | `**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` + |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 184 | `**Role:** ${ |
| 185 | config.welcome.role |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 186 | ? renderRole(await interaction.guild!.roles.fetch(config.welcome.role)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 187 | : "*None set*" |
| 188 | }\n` + |
| 189 | `**Ping:** ${ |
| 190 | config.welcome.ping |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 191 | ? renderRole(await interaction.guild!.roles.fetch(config.welcome.ping)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 192 | : "*None set*" |
| 193 | }\n` + |
| 194 | `**Channel:** ${ |
| 195 | config.welcome.channel |
| 196 | ? config.welcome.channel == "dm" |
| 197 | ? "DM" |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 198 | : renderChannel(await interaction.guild!.channels.fetch(config.welcome.channel)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 199 | : "*None set*" |
| 200 | }` |
| 201 | ) |
| 202 | .setStatus("Success") |
| 203 | .setEmoji("CHANNEL.TEXT.CREATE") |
| 204 | ], |
| 205 | components: [ |
| 206 | new MessageActionRow().addComponents([ |
| 207 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 208 | .setLabel(lastClicked == "clear-message" ? "Click again to confirm" : "Clear Message") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 209 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 210 | .setCustomId("clear-message") |
| 211 | .setDisabled(!config.welcome.message) |
| 212 | .setStyle("DANGER"), |
| 213 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 214 | .setLabel(lastClicked == "clear-role" ? "Click again to confirm" : "Clear Role") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 215 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 216 | .setCustomId("clear-role") |
| 217 | .setDisabled(!config.welcome.role) |
| 218 | .setStyle("DANGER"), |
| 219 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 220 | .setLabel(lastClicked == "clear-ping" ? "Click again to confirm" : "Clear Ping") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 221 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 222 | .setCustomId("clear-ping") |
| 223 | .setDisabled(!config.welcome.ping) |
| 224 | .setStyle("DANGER"), |
| 225 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 226 | .setLabel(lastClicked == "clear-channel" ? "Click again to confirm" : "Clear Channel") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 227 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 228 | .setCustomId("clear-channel") |
| 229 | .setDisabled(!config.welcome.channel) |
| 230 | .setStyle("DANGER"), |
| 231 | new MessageButton() |
| 232 | .setLabel("Set Channel to DM") |
| 233 | .setCustomId("set-channel-dm") |
| 234 | .setDisabled(config.welcome.channel == "dm") |
| 235 | .setStyle("SECONDARY") |
| 236 | ]) |
| 237 | ] |
| 238 | })) as Message; |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 239 | let i: MessageComponentInteraction; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 240 | try { |
| 241 | i = await m.awaitMessageComponent({ time: 300000 }); |
| 242 | } catch (e) { |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 243 | timedOut = true; |
| 244 | continue; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 245 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 246 | i.deferUpdate(); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 247 | if (i.customId == "clear-message") { |
| 248 | if (lastClicked == "clear-message") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 249 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 250 | "welcome.message": null |
| 251 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 252 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 253 | } else { |
| 254 | lastClicked = "clear-message"; |
| 255 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 256 | } else if (i.customId == "clear-role") { |
| 257 | if (lastClicked == "clear-role") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 258 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 259 | "welcome.role": null |
| 260 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 261 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 262 | } else { |
| 263 | lastClicked = "clear-role"; |
| 264 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 265 | } else if (i.customId == "clear-ping") { |
| 266 | if (lastClicked == "clear-ping") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 267 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 268 | "welcome.ping": null |
| 269 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 270 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 271 | } else { |
| 272 | lastClicked = "clear-ping"; |
| 273 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 274 | } else if (i.customId == "clear-channel") { |
| 275 | if (lastClicked == "clear-channel") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 276 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 277 | "welcome.channel": null |
| 278 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 279 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 280 | } else { |
| 281 | lastClicked = "clear-channel"; |
| 282 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 283 | } else if (i.customId == "set-channel-dm") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 284 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 285 | "welcome.channel": "dm" |
| 286 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 287 | lastClicked = null; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 288 | } |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 289 | } while (!timedOut); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 290 | await interaction.editReply({ |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 291 | embeds: [m.embeds[0]!.setFooter({ text: "Message timed out" })], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 292 | components: [] |
| 293 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 294 | }; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 295 | |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 296 | const check = (interaction: CommandInteraction) => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 297 | const member = interaction.member as Discord.GuildMember; |
| 298 | if (!member.permissions.has("MANAGE_GUILD")) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 299 | throw new Error("You must have the *Manage Server* permission to use this command"); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 300 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 301 | }; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 302 | |
| 303 | export { command }; |
| 304 | export { callback }; |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 305 | export { check }; |