pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame^] | 1 | import Discord, { MessageActionRow, MessageButton } from "discord.js"; |
| 2 | import generateEmojiEmbed from "../utils/generateEmojiEmbed.js"; |
| 3 | import getEmojiByName from "../utils/getEmojiByName.js"; |
| 4 | |
| 5 | export default async (guild, interaction?) => { |
| 6 | let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel; |
| 7 | c = c ? c : guild.channels.cache.find(ch => ch.type === "GUILD_TEXT" && ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") && ch.permissionsFor(guild.me).has("EMBED_LINKS")); |
| 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 | .setTitle("Logging") |
| 20 | .setDescription( |
| 21 | "Nucleus can log server events and keep you informed with what content is being posted to your server.\n" + |
| 22 | "We have 2 different types of logs, which each can be configured to send to a channel of your choice:\n" + |
| 23 | "**General Logs:** These are events like kicks and channel changes etc.\n" + |
| 24 | "**Warning Logs:** Warnings like NSFW avatars and spam etc that may require action by a server staff member.\n\n" + |
| 25 | "A general log channel can be set with `/settings log channel`\n" + |
| 26 | "A warning log channel can be set with `/settings warnings channel`" |
| 27 | ) |
| 28 | .setEmoji("NUCLEUS.LOGO") |
| 29 | .setStatus("Danger"), |
| 30 | new generateEmojiEmbed() |
| 31 | .setTitle("Moderation") |
| 32 | .setDescription( |
| 33 | "Nucleus has a number of commands that can be used to moderate your server.\n" + |
| 34 | "These commands are all found under `/mod`, and they include:\n" + |
| 35 | `**${getEmojiByName("PUNISH.WARN.YELLOW")} Warn:** The user is warned (via DM) that they violated server rules.\n` + |
| 36 | `**${getEmojiByName("PUNISH.CLEARHISTORY")} Clear:** Some messages from a user are deleted in a channel.\n` + |
| 37 | `**${getEmojiByName("PUNISH.MUTE.YELLOW")} Mute:** The user is unable to send messages or join voice chats.\n` + |
| 38 | `**${getEmojiByName("PUNISH.MUTE.GREEN")} Unmute:** The user is able to send messages in the server.\n` + |
| 39 | `**${getEmojiByName("PUNISH.KICK.RED")} Kick:** The user is removed from the server.\n` + |
| 40 | `**${getEmojiByName("PUNISH.SOFTBAN")} Softban:** Kicks the user, deleting their messages from every channel.\n` + |
| 41 | `**${getEmojiByName("PUNISH.BAN.RED")} Ban:** The user is removed from the server, and they are unable to rejoin.\n` + |
| 42 | `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.\n` |
| 43 | ) |
| 44 | .setEmoji("NUCLEUS.LOGO") |
| 45 | .setStatus("Danger"), |
| 46 | new generateEmojiEmbed() |
| 47 | .setTitle("Verify") |
| 48 | .setDescription( |
| 49 | "Nucleus has a verification system that allows users to prove they aren't bots.\n" + |
| 50 | "This is done by running `/verify` which sends a message only the user can see, giving them a link to a CAPTCHA to verify.\n" + |
| 51 | "After the user complete's the CAPTCHA, they are given a role and can use the permissions accordingly.\n" + |
| 52 | "You can set the role given with `/settings verify role`" |
| 53 | ) |
| 54 | .setEmoji("NUCLEUS.LOGO") |
| 55 | .setStatus("Danger"), |
| 56 | new generateEmojiEmbed() |
| 57 | .setTitle("Content Scanning") |
| 58 | .setDescription( |
| 59 | "Nucleus has a content scanning system that automatically scans links and images sent by users.\n" + |
| 60 | "Nucleus can detect, delete, and punish users for sending NSFW content, or links to scam or adult sites.\n" + |
| 61 | "You can set the threshold for this in `/settings automation`" |
| 62 | ) |
| 63 | .setEmoji("NUCLEUS.LOGO") |
| 64 | .setStatus("Danger"), |
| 65 | new generateEmojiEmbed() |
| 66 | .setTitle("Tickets") |
| 67 | .setDescription( |
| 68 | "Nucleus has a ticket system that allows users to create tickets and have a support team respond to them.\n" + |
| 69 | "Tickets can be created with `/ticket create` and a channel is created, pinging the user and support role.\n" + |
| 70 | "When the ticket is resolved, anyone can run `/ticket close` to archive it.\n" + |
| 71 | "Running `/ticket close` again will delete the ticket." |
| 72 | ) |
| 73 | .setEmoji("NUCLEUS.LOGO") |
| 74 | .setStatus("Danger") |
| 75 | ] |
| 76 | let m; |
| 77 | if (interaction) { |
| 78 | m = await interaction.reply({embeds: [ |
| 79 | new generateEmojiEmbed() |
| 80 | .setTitle("Welcome") |
| 81 | .setDescription(`One moment...`) |
| 82 | .setStatus("Danger") |
| 83 | .setEmoji("NUCLEUS.LOADING") |
| 84 | ], fetchReply: true, ephemeral: true}); |
| 85 | } else { |
| 86 | m = await c.send({embeds: [ |
| 87 | new generateEmojiEmbed() |
| 88 | .setTitle("Welcome") |
| 89 | .setDescription(`One moment...`) |
| 90 | .setStatus("Danger") |
| 91 | .setEmoji("NUCLEUS.LOADING") |
| 92 | ], fetchReply: true }); |
| 93 | } |
| 94 | let page = 0; |
| 95 | |
| 96 | let f = async (component) => { |
| 97 | return (component.member as Discord.GuildMember).permissions.has("MANAGE_GUILD"); |
| 98 | } |
| 99 | |
| 100 | while (true) { |
| 101 | if (interaction) { |
| 102 | await interaction.editReply({ |
| 103 | embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length}`})], |
| 104 | components: [new MessageActionRow().addComponents([ |
| 105 | new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0), |
| 106 | new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1), |
| 107 | new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER") |
| 108 | ])], |
| 109 | fetchReply: true |
| 110 | }); |
| 111 | } else { |
| 112 | await m.edit({ |
| 113 | embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length}`})], |
| 114 | components: [new MessageActionRow().addComponents([ |
| 115 | new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0), |
| 116 | new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1), |
| 117 | new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER") |
| 118 | ])], |
| 119 | fetchReply: true |
| 120 | }); |
| 121 | } |
| 122 | let i |
| 123 | try { |
| 124 | i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, componentType: "BUTTON", time: 600000}); |
| 125 | } catch(e) { break } |
| 126 | i.deferUpdate() |
| 127 | if (i.component.customId == "left") { |
| 128 | if (page > 0) page--; |
| 129 | } else if (i.component.customId == "right") { |
| 130 | if (page < pages.length - 1) page++; |
| 131 | } else if (i.component.customId == "close") { |
| 132 | if (interaction) { |
| 133 | interaction.delete(); |
| 134 | } else { |
| 135 | m.delete(); |
| 136 | } |
| 137 | return; |
| 138 | } else { |
| 139 | await m.delete() |
| 140 | break; |
| 141 | } |
| 142 | } |
| 143 | if (interaction) { |
| 144 | await interaction.editReply({ |
| 145 | embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length} | Message timed out`})], |
| 146 | components: [new MessageActionRow().addComponents([ |
| 147 | new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true), |
| 148 | new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true), |
| 149 | new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true) |
| 150 | ])] |
| 151 | }); |
| 152 | } else { |
| 153 | await m.edit({ |
| 154 | embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length} | Message timed out`})], |
| 155 | components: [new MessageActionRow().addComponents([ |
| 156 | new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true), |
| 157 | new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true), |
| 158 | new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true) |
| 159 | ])] |
| 160 | }); |
| 161 | } |
| 162 | } |