pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame^] | 1 | import { MessageActionRow, MessageButton } from "discord.js"; |
| 2 | import generateEmojiEmbed from "../utils/generateEmojiEmbed.js"; |
| 3 | import getEmojiByName from "../utils/getEmojiByName"; |
| 4 | |
| 5 | export const event = 'guildCreate'; |
| 6 | |
| 7 | export const callback = async (client, guild) => { |
| 8 | let pages = [ |
| 9 | new generateEmojiEmbed() |
| 10 | .setTitle("Welcome to Nucleus") |
| 11 | .setDescription( |
| 12 | "Thanks for adding Nucleus to your server\n\n" + |
| 13 | "On the next few pages you can find instructions on getting started, and commands you may want to set up\n\n" + |
| 14 | "If you need support, have questions or want features, you can let us know in [Clicks](https://discord.gg/bPaNnxe)" |
| 15 | ) |
| 16 | .setEmoji("NUCLEUS.LOGO") |
| 17 | .setStatus("Danger"), |
| 18 | new generateEmojiEmbed() |
| 19 | ] |
| 20 | let m = await guild.systemChannel.send({embeds: [ |
| 21 | new generateEmojiEmbed() |
| 22 | .setTitle("Welcome") |
| 23 | .setDescription(`One moment...`) |
| 24 | .setStatus("Danger") |
| 25 | .setEmoji("NUCLEUS.LOADING") |
| 26 | ], fetchReply: true }); |
| 27 | let page = 0; |
| 28 | |
| 29 | let f = async () => { |
| 30 | |
| 31 | } |
| 32 | |
| 33 | while (true) { |
| 34 | // edit interaction with pages[page] |
| 35 | await m.edit({ |
| 36 | embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length}`})], |
| 37 | components: [new MessageActionRow().addComponents([ |
| 38 | new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setDisabled(page === 0), |
| 39 | new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setDisabled(page === pages.length - 1) |
| 40 | ])], |
| 41 | fetchReply: true |
| 42 | }); |
| 43 | // wait for interaction |
| 44 | let interaction = await m.awaitMessageComponent({filter:f, componentType: "BUTTON", time: 60000}); |
| 45 | // change page variable accordingly |
| 46 | if (interaction.component.customId == "left") { |
| 47 | if (page > 0) page--; |
| 48 | } else if (interaction.component.customId == "right") { |
| 49 | if (page < pages.length - 1) page++; |
| 50 | } else { |
| 51 | await m.delete() |
| 52 | break; |
| 53 | } |
| 54 | // break if required |
| 55 | } |
| 56 | } |