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 | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 98 | .setEmoji("GUILD.ROLES.EDIT") |
| 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; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 175 | while (true) { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 176 | const config = await client.database.guilds.read(interaction.guild!.id); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 177 | m = (await interaction.editReply({ |
| 178 | embeds: [ |
| 179 | new EmojiEmbed() |
| 180 | .setTitle("Welcome Events") |
| 181 | .setDescription( |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 182 | `**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` + |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 183 | `**Role:** ${ |
| 184 | config.welcome.role |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 185 | ? renderRole(await interaction.guild!.roles.fetch(config.welcome.role)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 186 | : "*None set*" |
| 187 | }\n` + |
| 188 | `**Ping:** ${ |
| 189 | config.welcome.ping |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 190 | ? renderRole(await interaction.guild!.roles.fetch(config.welcome.ping)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 191 | : "*None set*" |
| 192 | }\n` + |
| 193 | `**Channel:** ${ |
| 194 | config.welcome.channel |
| 195 | ? config.welcome.channel == "dm" |
| 196 | ? "DM" |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 197 | : renderChannel(await interaction.guild!.channels.fetch(config.welcome.channel)) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 198 | : "*None set*" |
| 199 | }` |
| 200 | ) |
| 201 | .setStatus("Success") |
| 202 | .setEmoji("CHANNEL.TEXT.CREATE") |
| 203 | ], |
| 204 | components: [ |
| 205 | new MessageActionRow().addComponents([ |
| 206 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 207 | .setLabel(lastClicked == "clear-message" ? "Click again to confirm" : "Clear Message") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 208 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 209 | .setCustomId("clear-message") |
| 210 | .setDisabled(!config.welcome.message) |
| 211 | .setStyle("DANGER"), |
| 212 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 213 | .setLabel(lastClicked == "clear-role" ? "Click again to confirm" : "Clear Role") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 214 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 215 | .setCustomId("clear-role") |
| 216 | .setDisabled(!config.welcome.role) |
| 217 | .setStyle("DANGER"), |
| 218 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 219 | .setLabel(lastClicked == "clear-ping" ? "Click again to confirm" : "Clear Ping") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 220 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 221 | .setCustomId("clear-ping") |
| 222 | .setDisabled(!config.welcome.ping) |
| 223 | .setStyle("DANGER"), |
| 224 | new MessageButton() |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 225 | .setLabel(lastClicked == "clear-channel" ? "Click again to confirm" : "Clear Channel") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 226 | .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| 227 | .setCustomId("clear-channel") |
| 228 | .setDisabled(!config.welcome.channel) |
| 229 | .setStyle("DANGER"), |
| 230 | new MessageButton() |
| 231 | .setLabel("Set Channel to DM") |
| 232 | .setCustomId("set-channel-dm") |
| 233 | .setDisabled(config.welcome.channel == "dm") |
| 234 | .setStyle("SECONDARY") |
| 235 | ]) |
| 236 | ] |
| 237 | })) as Message; |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 238 | let i: MessageComponentInteraction; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 239 | try { |
| 240 | i = await m.awaitMessageComponent({ time: 300000 }); |
| 241 | } catch (e) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 242 | break; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 243 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 244 | i.deferUpdate(); |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 245 | if (i.customId == "clear-message") { |
| 246 | if (lastClicked == "clear-message") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 247 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 248 | "welcome.message": null |
| 249 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 250 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 251 | } else { |
| 252 | lastClicked = "clear-message"; |
| 253 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 254 | } else if (i.customId == "clear-role") { |
| 255 | if (lastClicked == "clear-role") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 256 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 257 | "welcome.role": null |
| 258 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 259 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 260 | } else { |
| 261 | lastClicked = "clear-role"; |
| 262 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 263 | } else if (i.customId == "clear-ping") { |
| 264 | if (lastClicked == "clear-ping") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 265 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 266 | "welcome.ping": null |
| 267 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 268 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 269 | } else { |
| 270 | lastClicked = "clear-ping"; |
| 271 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 272 | } else if (i.customId == "clear-channel") { |
| 273 | if (lastClicked == "clear-channel") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 274 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 275 | "welcome.channel": null |
| 276 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 277 | lastClicked = null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 278 | } else { |
| 279 | lastClicked = "clear-channel"; |
| 280 | } |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 281 | } else if (i.customId == "set-channel-dm") { |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 282 | await client.database.guilds.write(interaction.guild!.id, { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 283 | "welcome.channel": "dm" |
| 284 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 285 | lastClicked = null; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 286 | } |
| 287 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 288 | await interaction.editReply({ |
pineafan | 4e42594 | 2022-08-08 22:01:47 +0100 | [diff] [blame] | 289 | embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })], |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 290 | components: [] |
| 291 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 292 | }; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 293 | |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 294 | const check = (interaction: CommandInteraction) => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 295 | const member = interaction.member as Discord.GuildMember; |
| 296 | if (!member.permissions.has("MANAGE_GUILD")) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 297 | 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] | 298 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 299 | }; |
pineafan | 41d9356 | 2022-07-30 22:10:15 +0100 | [diff] [blame] | 300 | |
| 301 | export { command }; |
| 302 | export { callback }; |
Skyler Grey | 1a67e18 | 2022-08-04 23:05:44 +0100 | [diff] [blame] | 303 | export { check }; |