pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 1 | import { |
| 2 | ActionRowBuilder, |
| 3 | AttachmentBuilder, |
| 4 | ButtonBuilder, |
| 5 | ButtonInteraction, |
| 6 | ButtonStyle, |
| 7 | ChannelType, |
| 8 | CommandInteraction, |
| 9 | ComponentType, |
| 10 | Guild, |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 11 | GuildTextBasedChannel, |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 12 | ModalBuilder, |
| 13 | ModalSubmitInteraction, |
| 14 | TextInputBuilder, |
| 15 | TextInputStyle |
| 16 | } from "discord.js"; |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 17 | import type { SlashCommandSubcommandBuilder } from "discord.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 18 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 19 | import client from "../../utils/client.js"; |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 20 | import config from "../../config/main.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 21 | |
| 22 | const command = (builder: SlashCommandSubcommandBuilder) => |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 23 | builder.setName("stats").setDescription("Gets the bot's stats"); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 24 | |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 25 | const confirm = async (interaction: CommandInteraction) => { |
| 26 | const requiredTexts = [ |
| 27 | "just do it", |
| 28 | "yes, do as i say!", |
| 29 | "clicksminuteper/nucleus", |
| 30 | "i've said it once i'll say it again", |
| 31 | "no, i've changed my mind", |
| 32 | "this incident will be reported", |
| 33 | "coded told me to", |
| 34 | "mini told me to", |
| 35 | "pinea told me to", |
| 36 | "what's a java script", |
| 37 | "it's a feature not a bug", |
| 38 | "that never happened during testing" |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 39 | ]; |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 40 | const chosen = requiredTexts[Math.floor(Math.random() * (requiredTexts.length - 1))]!; |
| 41 | |
| 42 | const modal = new ModalBuilder() |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 43 | .addComponents( |
| 44 | new ActionRowBuilder<TextInputBuilder>().addComponents( |
| 45 | new TextInputBuilder() |
| 46 | .setStyle(TextInputStyle.Short) |
| 47 | .setLabel(`Type "${chosen}" below`) |
| 48 | .setCustomId("confirm") |
| 49 | .setPlaceholder("Guild ID") |
| 50 | .setMinLength(chosen.length) |
| 51 | .setMaxLength(chosen.length) |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 52 | ) |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 53 | ) |
| 54 | .setTitle("Admin Panel") |
| 55 | .setCustomId("adminPanel"); |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 56 | await interaction.showModal(modal); |
| 57 | let out: ModalSubmitInteraction; |
| 58 | try { |
| 59 | out = await interaction.awaitModalSubmit({ |
| 60 | filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id, |
| 61 | time: 300000 |
| 62 | }); |
| 63 | } catch { |
| 64 | return; |
| 65 | } |
| 66 | await out.deferUpdate(); |
| 67 | const typed = out.fields.getTextInputValue("confirm"); |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 68 | return typed.toLowerCase() === chosen.toLowerCase(); |
| 69 | }; |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 70 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 71 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 72 | const description = `**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``; |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 73 | const m = await interaction.reply({ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 74 | embeds: [ |
| 75 | new EmojiEmbed() |
| 76 | .setTitle("Stats") |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 77 | .setDescription(description) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 78 | .setStatus("Success") |
TheCodedProf | 4a6d571 | 2023-01-19 15:54:40 -0500 | [diff] [blame] | 79 | .setEmoji("SETTINGS.STATS.GREEN") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 80 | ], |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 81 | ephemeral: true, |
| 82 | fetchReply: true |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 83 | }); |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 84 | if (config.owners.includes(interaction.user.id)) { |
Skyler Grey | f4f21c4 | 2023-03-08 14:36:29 +0000 | [diff] [blame] | 85 | await interaction.editReply({ |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 86 | embeds: [ |
| 87 | new EmojiEmbed() |
| 88 | .setTitle("Admin") |
| 89 | .setDescription(description) |
| 90 | .setStatus("Success") |
| 91 | .setEmoji("SETTINGS.STATS.GREEN") |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 92 | ], |
| 93 | components: [ |
| 94 | new ActionRowBuilder<ButtonBuilder>().addComponents( |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 95 | new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary), |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 96 | new ButtonBuilder() |
| 97 | .setCustomId("announce") |
| 98 | .setLabel("Announce to all Guilds") |
| 99 | .setStyle(ButtonStyle.Danger) |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 100 | ) |
| 101 | ] |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 102 | }); |
| 103 | |
| 104 | const modal = new ModalBuilder() |
| 105 | .addComponents( |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 106 | new ActionRowBuilder<TextInputBuilder>().addComponents( |
| 107 | new TextInputBuilder() |
| 108 | .setStyle(TextInputStyle.Short) |
| 109 | .setLabel("Guild ID") |
| 110 | .setCustomId("guildID") |
| 111 | .setPlaceholder("Guild ID") |
| 112 | .setMinLength(16) |
| 113 | .setMaxLength(25) |
| 114 | ) |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 115 | ) |
| 116 | .setTitle("Admin Panel") |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 117 | .setCustomId("adminPanel"); |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 118 | let i1: ButtonInteraction; |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 119 | const channel = await client.channels.fetch(interaction.channelId); |
| 120 | if ( |
| 121 | !channel || |
| 122 | [ChannelType.GuildCategory, ChannelType.GroupDM, ChannelType.GuildStageVoice].includes(channel.type) |
| 123 | ) |
| 124 | return; |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 125 | // console.log(interaction) |
| 126 | if (!("awaitMessageComponent" in channel)) return; |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 127 | let GuildID = interaction.guildId; |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 128 | try { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 129 | i1 = await m.awaitMessageComponent<ComponentType.Button>({ |
| 130 | filter: (i) => i.user.id === interaction.user.id, |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 131 | time: 300000 |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 132 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 133 | } catch (e) { |
| 134 | console.log(e); |
pineafan | 1e462ab | 2023-03-07 21:34:06 +0000 | [diff] [blame] | 135 | return; |
| 136 | } |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 137 | switch (i1.customId) { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 138 | case "admin": { |
| 139 | if (!GuildID) { |
| 140 | await i1.showModal(modal); |
| 141 | let out: ModalSubmitInteraction; |
| 142 | try { |
| 143 | out = await i1.awaitModalSubmit({ |
| 144 | filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id, |
| 145 | time: 300000 |
| 146 | }); |
| 147 | } catch { |
| 148 | return; |
| 149 | } |
| 150 | await out.deferUpdate(); |
| 151 | GuildID = out.fields.getTextInputValue("guildID"); |
| 152 | } else if (!client.guilds.cache.has(GuildID)) { |
| 153 | await interaction.editReply({ |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 154 | embeds: [ |
| 155 | new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger") |
| 156 | ], |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 157 | components: [] |
| 158 | }); |
| 159 | } |
| 160 | |
| 161 | await interaction.editReply({ |
| 162 | embeds: [], |
| 163 | components: [ |
| 164 | new ActionRowBuilder<ButtonBuilder>().addComponents( |
| 165 | new ButtonBuilder().setCustomId("stats").setLabel("Stats").setStyle(ButtonStyle.Primary), |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 166 | new ButtonBuilder() |
| 167 | .setCustomId("data") |
| 168 | .setLabel("Guild data") |
| 169 | .setStyle(ButtonStyle.Secondary), |
| 170 | new ButtonBuilder() |
| 171 | .setCustomId("cache") |
| 172 | .setLabel("Reset cache") |
| 173 | .setStyle(ButtonStyle.Success), |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 174 | new ButtonBuilder().setCustomId("leave").setLabel("Leave").setStyle(ButtonStyle.Danger), |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 175 | new ButtonBuilder() |
| 176 | .setCustomId("purge") |
| 177 | .setLabel("Delete data") |
| 178 | .setStyle(ButtonStyle.Danger) |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 179 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 180 | ] |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 181 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 182 | let i; |
| 183 | try { |
| 184 | i = await m.awaitMessageComponent<ComponentType.Button>({ |
| 185 | filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, |
| 186 | time: 300000 |
| 187 | }); |
| 188 | } catch { |
| 189 | return; |
| 190 | } |
| 191 | const guild = (await client.guilds.fetch(GuildID)) as Guild | null; |
| 192 | if (!guild) { |
| 193 | await i.deferUpdate(); |
| 194 | await interaction.editReply({ |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 195 | embeds: [ |
| 196 | new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger") |
| 197 | ], |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 198 | components: [] |
| 199 | }); |
| 200 | return; |
| 201 | } |
| 202 | if (i.customId === "stats") { |
| 203 | await i.deferUpdate(); |
| 204 | await interaction.editReply({ |
| 205 | embeds: [ |
| 206 | new EmojiEmbed() |
| 207 | .setTitle("Stats") |
| 208 | .setDescription( |
| 209 | `**Name:** ${guild.name}\n` + |
| 210 | `**ID:** \`${guild.id}\`\n` + |
| 211 | `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` + |
| 212 | `**Member Count:** ${guild.memberCount}\n` + |
| 213 | `**Created:** <t:${guild.createdTimestamp}:F>\n` + |
| 214 | `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` + |
| 215 | `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n` |
| 216 | ) |
| 217 | .setStatus("Success") |
| 218 | .setEmoji("SETTINGS.STATS.GREEN") |
| 219 | ] |
| 220 | }); |
| 221 | } else if (i.customId === "leave") { |
| 222 | if (!(await confirm(interaction))) { |
| 223 | await interaction.editReply({ |
| 224 | embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], |
| 225 | components: [] |
| 226 | }); |
| 227 | return; |
| 228 | } |
| 229 | await guild.leave(); |
| 230 | await interaction.editReply({ |
| 231 | embeds: [ |
| 232 | new EmojiEmbed() |
| 233 | .setTitle("Left") |
| 234 | .setDescription(`Left ${guild.name}`) |
| 235 | .setStatus("Success") |
| 236 | .setEmoji("SETTINGS.STATS.GREEN") |
| 237 | ], |
| 238 | components: [] |
| 239 | }); |
| 240 | } else if (i.customId === "data") { |
| 241 | await i.deferUpdate(); |
| 242 | // Get all the data and convert to a string |
| 243 | const data = await client.database.guilds.read(guild.id); |
| 244 | const stringified = JSON.stringify(data, null, 2); |
| 245 | const buffer = Buffer.from(stringified); |
| 246 | const attachment = new AttachmentBuilder(buffer).setName("data.json"); |
| 247 | await interaction.editReply({ |
| 248 | embeds: [ |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 249 | new EmojiEmbed() |
| 250 | .setTitle("Data") |
| 251 | .setDescription(`Data for ${guild.name}`) |
| 252 | .setStatus("Success") |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 253 | ], |
| 254 | components: [], |
| 255 | files: [attachment] |
| 256 | }); |
| 257 | } else if (i.customId === "purge") { |
| 258 | if (!(await confirm(interaction))) { |
| 259 | await interaction.editReply({ |
| 260 | embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], |
| 261 | components: [] |
| 262 | }); |
| 263 | return; |
| 264 | } |
| 265 | await client.database.guilds.delete(GuildID); |
| 266 | await client.database.history.delete(GuildID); |
| 267 | await client.database.notes.delete(GuildID); |
| 268 | await client.database.transcripts.deleteAll(GuildID); |
| 269 | await interaction.editReply({ |
| 270 | embeds: [ |
| 271 | new EmojiEmbed() |
| 272 | .setTitle("Purge") |
| 273 | .setDescription(`Deleted data for ${guild.name}`) |
| 274 | .setStatus("Success") |
| 275 | .setEmoji("SETTINGS.STATS.GREEN") |
| 276 | ], |
| 277 | components: [] |
| 278 | }); |
| 279 | } else if (i.customId === "cache") { |
| 280 | await i.deferUpdate(); |
| 281 | await client.memory.forceUpdate(guild.id); |
| 282 | await interaction.editReply({ |
| 283 | embeds: [ |
| 284 | new EmojiEmbed() |
| 285 | .setTitle("Cache") |
| 286 | .setDescription(`Reset cache for ${guild.name}`) |
| 287 | .setStatus("Success") |
| 288 | .setEmoji("SETTINGS.STATS.GREEN") |
| 289 | ], |
| 290 | components: [] |
| 291 | }); |
| 292 | } |
| 293 | break; |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 294 | } |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 295 | case "announce": { |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 296 | const channelsToNotify = await client.database.guilds.staffChannels(); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 297 | const modal2 = new ModalBuilder() |
| 298 | .addComponents( |
| 299 | new ActionRowBuilder<TextInputBuilder>().addComponents( |
| 300 | new TextInputBuilder() |
| 301 | .setStyle(TextInputStyle.Paragraph) |
| 302 | .setLabel("Announcement") |
| 303 | .setCustomId("announcement") |
| 304 | .setPlaceholder("Announcement...") |
| 305 | ) |
| 306 | ) |
| 307 | .setTitle("Announcement") |
| 308 | .setCustomId("announce"); |
| 309 | await i1.showModal(modal2); |
| 310 | let out: ModalSubmitInteraction; |
| 311 | try { |
| 312 | out = await i1.awaitModalSubmit({ |
| 313 | filter: (i) => i.customId === "announce" && i.user.id === interaction.user.id, |
| 314 | time: 300000 |
| 315 | }); |
| 316 | } catch { |
| 317 | return; |
| 318 | } |
| 319 | await out.deferUpdate(); |
| 320 | const announcement = out.fields.getTextInputValue("announcement"); |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 321 | await interaction.editReply({ |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 322 | embeds: [ |
| 323 | new EmojiEmbed() |
| 324 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 325 | .setDescription( |
| 326 | `Announcement will be sent to ${channelsToNotify.length} channels.\n\n${announcement}` |
| 327 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 328 | .setStatus("Success") |
| 329 | .setEmoji("SETTINGS.STATS.GREEN") |
| 330 | ], |
| 331 | components: [ |
| 332 | new ActionRowBuilder<ButtonBuilder>().addComponents( |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 333 | new ButtonBuilder() |
| 334 | .setCustomId("confirm") |
| 335 | .setLabel("Confirm") |
| 336 | .setStyle(ButtonStyle.Success), |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 337 | new ButtonBuilder().setCustomId("cancel").setLabel("Cancel").setStyle(ButtonStyle.Danger) |
| 338 | ) |
| 339 | ] |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 340 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 341 | |
| 342 | let i; |
| 343 | try { |
| 344 | i = await m.awaitMessageComponent<ComponentType.Button>({ |
| 345 | filter: (i) => i.user.id === interaction.user.id, |
| 346 | time: 300000 |
| 347 | }); |
| 348 | } catch { |
| 349 | return; |
| 350 | } |
| 351 | if (i.customId === "confirm") { |
| 352 | await i.deferUpdate(); |
| 353 | await interaction.editReply({ |
| 354 | embeds: [ |
| 355 | new EmojiEmbed() |
| 356 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 357 | .setDescription( |
| 358 | `Sending to ${channelsToNotify.length} channels. Preview:\n\n${announcement}` |
| 359 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 360 | .setStatus("Success") |
| 361 | .setEmoji("SETTINGS.STATS.GREEN") |
| 362 | ], |
| 363 | components: [] |
| 364 | }); |
| 365 | const announcementEmbed = new EmojiEmbed() |
| 366 | .setTitle("Developer Announcement") |
| 367 | .setDescription(announcement) |
| 368 | .setStatus("Danger") |
| 369 | .setEmoji("NUCLEUS.LOGO") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 370 | .setFooter({ |
| 371 | text: `Sent by ${interaction.user.username}`, |
| 372 | iconURL: interaction.user.displayAvatarURL() |
| 373 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 374 | for (const channel of channelsToNotify) { |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 375 | const ch = (await client.channels.fetch(channel)) as GuildTextBasedChannel | null; |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 376 | if (!ch) continue; |
| 377 | await ch.send({ |
| 378 | embeds: [announcementEmbed] |
| 379 | }); |
| 380 | } |
| 381 | await interaction.editReply({ |
| 382 | embeds: [ |
| 383 | new EmojiEmbed() |
| 384 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 385 | .setDescription( |
| 386 | `Sent to ${channelsToNotify.length} channels. Preview:\n\n${announcement}` |
| 387 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 388 | .setStatus("Success") |
| 389 | .setEmoji("SETTINGS.STATS.GREEN") |
| 390 | ], |
| 391 | components: [] |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame^] | 392 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 393 | } else if (i.customId === "cancel") { |
| 394 | await i.deferUpdate(); |
| 395 | await interaction.editReply({ |
| 396 | embeds: [new EmojiEmbed().setTitle("Announcement Cancelled").setStatus("Danger")], |
| 397 | components: [] |
| 398 | }); |
| 399 | } |
| 400 | break; |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 401 | } |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 402 | } |
| 403 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 404 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 405 | |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 406 | export { command }; |
| 407 | export { callback }; |