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; |
Skyler Grey | a325d26 | 2023-03-15 00:08:01 +0000 | [diff] [blame] | 192 | await i.deferUpdate(); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 193 | if (!guild) { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 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") { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 203 | await interaction.editReply({ |
| 204 | embeds: [ |
| 205 | new EmojiEmbed() |
| 206 | .setTitle("Stats") |
| 207 | .setDescription( |
| 208 | `**Name:** ${guild.name}\n` + |
| 209 | `**ID:** \`${guild.id}\`\n` + |
| 210 | `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` + |
| 211 | `**Member Count:** ${guild.memberCount}\n` + |
| 212 | `**Created:** <t:${guild.createdTimestamp}:F>\n` + |
| 213 | `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` + |
| 214 | `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n` |
| 215 | ) |
| 216 | .setStatus("Success") |
| 217 | .setEmoji("SETTINGS.STATS.GREEN") |
| 218 | ] |
| 219 | }); |
| 220 | } else if (i.customId === "leave") { |
| 221 | if (!(await confirm(interaction))) { |
| 222 | await interaction.editReply({ |
| 223 | embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], |
| 224 | components: [] |
| 225 | }); |
| 226 | return; |
| 227 | } |
| 228 | await guild.leave(); |
| 229 | await interaction.editReply({ |
| 230 | embeds: [ |
| 231 | new EmojiEmbed() |
| 232 | .setTitle("Left") |
| 233 | .setDescription(`Left ${guild.name}`) |
| 234 | .setStatus("Success") |
| 235 | .setEmoji("SETTINGS.STATS.GREEN") |
| 236 | ], |
| 237 | components: [] |
| 238 | }); |
| 239 | } else if (i.customId === "data") { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 240 | // Get all the data and convert to a string |
| 241 | const data = await client.database.guilds.read(guild.id); |
| 242 | const stringified = JSON.stringify(data, null, 2); |
| 243 | const buffer = Buffer.from(stringified); |
| 244 | const attachment = new AttachmentBuilder(buffer).setName("data.json"); |
| 245 | await interaction.editReply({ |
| 246 | embeds: [ |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 247 | new EmojiEmbed() |
| 248 | .setTitle("Data") |
| 249 | .setDescription(`Data for ${guild.name}`) |
| 250 | .setStatus("Success") |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 251 | ], |
| 252 | components: [], |
| 253 | files: [attachment] |
| 254 | }); |
| 255 | } else if (i.customId === "purge") { |
| 256 | if (!(await confirm(interaction))) { |
| 257 | await interaction.editReply({ |
| 258 | embeds: [new EmojiEmbed().setTitle("No changes were made").setStatus("Danger")], |
| 259 | components: [] |
| 260 | }); |
| 261 | return; |
| 262 | } |
| 263 | await client.database.guilds.delete(GuildID); |
| 264 | await client.database.history.delete(GuildID); |
| 265 | await client.database.notes.delete(GuildID); |
| 266 | await client.database.transcripts.deleteAll(GuildID); |
| 267 | await interaction.editReply({ |
| 268 | embeds: [ |
| 269 | new EmojiEmbed() |
| 270 | .setTitle("Purge") |
| 271 | .setDescription(`Deleted data for ${guild.name}`) |
| 272 | .setStatus("Success") |
| 273 | .setEmoji("SETTINGS.STATS.GREEN") |
| 274 | ], |
| 275 | components: [] |
| 276 | }); |
| 277 | } else if (i.customId === "cache") { |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 278 | await client.memory.forceUpdate(guild.id); |
| 279 | await interaction.editReply({ |
| 280 | embeds: [ |
| 281 | new EmojiEmbed() |
| 282 | .setTitle("Cache") |
| 283 | .setDescription(`Reset cache for ${guild.name}`) |
| 284 | .setStatus("Success") |
| 285 | .setEmoji("SETTINGS.STATS.GREEN") |
| 286 | ], |
| 287 | components: [] |
| 288 | }); |
| 289 | } |
| 290 | break; |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 291 | } |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 292 | case "announce": { |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 293 | const channelsToNotify = await client.database.guilds.staffChannels(); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 294 | const modal2 = new ModalBuilder() |
| 295 | .addComponents( |
| 296 | new ActionRowBuilder<TextInputBuilder>().addComponents( |
| 297 | new TextInputBuilder() |
| 298 | .setStyle(TextInputStyle.Paragraph) |
| 299 | .setLabel("Announcement") |
| 300 | .setCustomId("announcement") |
| 301 | .setPlaceholder("Announcement...") |
| 302 | ) |
| 303 | ) |
| 304 | .setTitle("Announcement") |
| 305 | .setCustomId("announce"); |
| 306 | await i1.showModal(modal2); |
| 307 | let out: ModalSubmitInteraction; |
| 308 | try { |
| 309 | out = await i1.awaitModalSubmit({ |
| 310 | filter: (i) => i.customId === "announce" && i.user.id === interaction.user.id, |
| 311 | time: 300000 |
| 312 | }); |
| 313 | } catch { |
| 314 | return; |
| 315 | } |
| 316 | await out.deferUpdate(); |
| 317 | const announcement = out.fields.getTextInputValue("announcement"); |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 318 | await interaction.editReply({ |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 319 | embeds: [ |
| 320 | new EmojiEmbed() |
| 321 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 322 | .setDescription( |
| 323 | `Announcement will be sent to ${channelsToNotify.length} channels.\n\n${announcement}` |
| 324 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 325 | .setStatus("Success") |
| 326 | .setEmoji("SETTINGS.STATS.GREEN") |
| 327 | ], |
| 328 | components: [ |
| 329 | new ActionRowBuilder<ButtonBuilder>().addComponents( |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 330 | new ButtonBuilder() |
| 331 | .setCustomId("confirm") |
| 332 | .setLabel("Confirm") |
| 333 | .setStyle(ButtonStyle.Success), |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 334 | new ButtonBuilder().setCustomId("cancel").setLabel("Cancel").setStyle(ButtonStyle.Danger) |
| 335 | ) |
| 336 | ] |
TheCodedProf | 35e7371 | 2023-03-10 17:35:35 -0500 | [diff] [blame] | 337 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 338 | |
| 339 | let i; |
| 340 | try { |
| 341 | i = await m.awaitMessageComponent<ComponentType.Button>({ |
| 342 | filter: (i) => i.user.id === interaction.user.id, |
| 343 | time: 300000 |
| 344 | }); |
| 345 | } catch { |
| 346 | return; |
| 347 | } |
| 348 | if (i.customId === "confirm") { |
| 349 | await i.deferUpdate(); |
| 350 | await interaction.editReply({ |
| 351 | embeds: [ |
| 352 | new EmojiEmbed() |
| 353 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 354 | .setDescription( |
| 355 | `Sending to ${channelsToNotify.length} channels. Preview:\n\n${announcement}` |
| 356 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 357 | .setStatus("Success") |
| 358 | .setEmoji("SETTINGS.STATS.GREEN") |
| 359 | ], |
| 360 | components: [] |
| 361 | }); |
| 362 | const announcementEmbed = new EmojiEmbed() |
| 363 | .setTitle("Developer Announcement") |
| 364 | .setDescription(announcement) |
| 365 | .setStatus("Danger") |
| 366 | .setEmoji("NUCLEUS.LOGO") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 367 | .setFooter({ |
| 368 | text: `Sent by ${interaction.user.username}`, |
| 369 | iconURL: interaction.user.displayAvatarURL() |
| 370 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 371 | for (const channel of channelsToNotify) { |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 372 | const ch = (await client.channels.fetch(channel)) as GuildTextBasedChannel | null; |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 373 | if (!ch) continue; |
| 374 | await ch.send({ |
| 375 | embeds: [announcementEmbed] |
| 376 | }); |
| 377 | } |
| 378 | await interaction.editReply({ |
| 379 | embeds: [ |
| 380 | new EmojiEmbed() |
| 381 | .setTitle("Announcement") |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 382 | .setDescription( |
| 383 | `Sent to ${channelsToNotify.length} channels. Preview:\n\n${announcement}` |
| 384 | ) |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 385 | .setStatus("Success") |
| 386 | .setEmoji("SETTINGS.STATS.GREEN") |
| 387 | ], |
| 388 | components: [] |
TheCodedProf | 528de57 | 2023-03-11 17:28:29 -0500 | [diff] [blame] | 389 | }); |
TheCodedProf | a38cbb3 | 2023-03-11 17:22:25 -0500 | [diff] [blame] | 390 | } else if (i.customId === "cancel") { |
| 391 | await i.deferUpdate(); |
| 392 | await interaction.editReply({ |
| 393 | embeds: [new EmojiEmbed().setTitle("Announcement Cancelled").setStatus("Danger")], |
| 394 | components: [] |
| 395 | }); |
| 396 | } |
| 397 | break; |
TheCodedProf | ca29ebb | 2023-03-10 17:40:09 -0500 | [diff] [blame] | 398 | } |
TheCodedProf | e92b9b5 | 2023-03-06 17:07:34 -0500 | [diff] [blame] | 399 | } |
| 400 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 401 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 402 | |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 403 | export { command }; |
| 404 | export { callback }; |