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