blob: 8e0e6cd1a812b608fa104f14c134dd6f5aa22e07 [file] [log] [blame]
pineafanea063042022-05-19 19:08:44 +01001import { SelectMenuOption } from '@discordjs/builders';
pineafanad54d752022-04-18 19:01:43 +01002import Discord, { MessageActionRow, MessageButton } from "discord.js";
pineafan4edb7762022-06-26 19:21:04 +01003import EmojiEmbed from "../utils/generateEmojiEmbed.js";
pineafanad54d752022-04-18 19:01:43 +01004import getEmojiByName from "../utils/getEmojiByName.js";
pineafan34369e62022-05-18 16:52:37 +01005import createPageIndicator from "../utils/createPageIndicator.js";
pineafanad54d752022-04-18 19:01:43 +01006
pineafanea063042022-05-19 19:08:44 +01007class Embed {
8 embed: Discord.MessageEmbed;
9 title: string;
10 description: string = "";
11 pageId: number = 0;
12 setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
13 setTitle(title: string) { this.title = title; return this; }
14 setDescription(description: string) { this.description = description; return this; }
15 setPageId(pageId: number) { this.pageId = pageId; return this; }
16}
17
pineafanad54d752022-04-18 19:01:43 +010018export default async (guild, interaction?) => {
pineafane625d782022-05-09 18:04:32 +010019 let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
20 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"));
pineafanad54d752022-04-18 19:01:43 +010021 let pages = [
pineafanea063042022-05-19 19:08:44 +010022 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010023 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010024 .setTitle("Welcome to Nucleus")
25 .setDescription(
26 "Thanks for adding Nucleus to your server\n\n" +
27 "On the next few pages you can find instructions on getting started, and commands you may want to set up\n\n" +
28 "If you need support, have questions or want features, you can let us know in [Clicks](https://discord.gg/bPaNnxe)"
29 )
30 .setEmoji("NUCLEUS.LOGO")
31 .setStatus("Danger")
32 ).setTitle("Welcome").setDescription("About Nucleus").setPageId(0),
33 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010034 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010035 .setTitle("Logging")
36 .setDescription(
37 "Nucleus can log server events and keep you informed with what content is being posted to your server.\n" +
38 "We have 2 different types of logs, which each can be configured to send to a channel of your choice:\n" +
39 "**General Logs:** These are events like kicks and channel changes etc.\n" +
40 "**Warning Logs:** Warnings like NSFW avatars and spam etc that may require action by a server staff member.\n\n" +
41 "A general log channel can be set with `/settings log channel`\n" +
42 "A warning log channel can be set with `/settings warnings channel`"
43 )
44 .setEmoji("NUCLEUS.LOGO")
45 .setStatus("Danger")
46 ).setTitle("Logging").setDescription("Logging, staff warning logs etc.").setPageId(1),
47 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010048 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010049 .setTitle("Moderation")
50 .setDescription(
51 "Nucleus has a number of commands that can be used to moderate your server.\n" +
52 "These commands are all found under `/mod`, and they include:\n" +
53 `**${getEmojiByName("PUNISH.WARN.YELLOW")} Warn:** The user is warned (via DM) that they violated server rules.\n` +
54 `**${getEmojiByName("PUNISH.CLEARHISTORY")} Clear:** Some messages from a user are deleted in a channel.\n` +
55 `**${getEmojiByName("PUNISH.MUTE.YELLOW")} Mute:** The user is unable to send messages or join voice chats.\n` +
56 `**${getEmojiByName("PUNISH.MUTE.GREEN")} Unmute:** The user is able to send messages in the server.\n` +
57 `**${getEmojiByName("PUNISH.KICK.RED")} Kick:** The user is removed from the server.\n` +
58 `**${getEmojiByName("PUNISH.SOFTBAN")} Softban:** Kicks the user, deleting their messages from every channel.\n` +
59 `**${getEmojiByName("PUNISH.BAN.RED")} Ban:** The user is removed from the server, and they are unable to rejoin.\n` +
60 `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.`
61 )
pineafanad54d752022-04-18 19:01:43 +010062 .setEmoji("NUCLEUS.LOGO")
63 .setStatus("Danger")
pineafanea063042022-05-19 19:08:44 +010064 ).setTitle("Moderation").setDescription("Basic moderation commands").setPageId(2),
65 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010066 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010067 .setTitle("Verify")
68 .setDescription(
69 "Nucleus has a verification system that allows users to prove they aren't bots.\n" +
70 "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" +
71 "After the user complete's the CAPTCHA, they are given a role and can use the permissions accordingly.\n" +
72 "You can set the role given with `/settings verify role`"
73 )
74 .setEmoji("NUCLEUS.LOGO")
75 .setStatus("Danger")
76 ).setTitle("Verify").setDescription("Captcha verification system").setPageId(3),
77 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010078 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010079 .setTitle("Content Scanning")
80 .setDescription(
81 "Nucleus has a content scanning system that automatically scans links and images sent by users.\n" +
82 "Nucleus can detect, delete, and punish users for sending NSFW content, or links to scam or adult sites.\n" +
83 "You can set the threshold for this in `/settings automation`"
84 )
85 .setEmoji("NUCLEUS.LOGO")
86 .setStatus("Danger")
87 ).setTitle("Content Scanning").setDescription("Content (NSFW, malware, scams) scanning").setPageId(4),
88 new Embed()
pineafan4edb7762022-06-26 19:21:04 +010089 .setEmbed(new EmojiEmbed()
pineafanea063042022-05-19 19:08:44 +010090 .setTitle("Tickets")
91 .setDescription(
92 "Nucleus has a ticket system that allows users to create tickets and have a support team respond to them.\n" +
93 "Tickets can be created with `/ticket create` and a channel is created, pinging the user and support role.\n" +
94 "When the ticket is resolved, anyone can run `/ticket close` to archive it.\n" +
95 "Running `/ticket close` again will delete the ticket."
96 )
97 .setEmoji("NUCLEUS.LOGO")
98 .setStatus("Danger")
pineafan6702cef2022-06-13 17:52:37 +010099 ).setTitle("Tickets").setDescription("Ticket system").setPageId(5),
100 new Embed()
pineafan4edb7762022-06-26 19:21:04 +0100101 .setEmbed(new EmojiEmbed()
pineafan6702cef2022-06-13 17:52:37 +0100102 .setTitle("Tags")
103 .setDescription(
104 "Add a tag system to your server with the `/tag` and `/tags` commands.\n" +
105 "To create a tag, type `/tags create <tag name> <tag content>`.\n" +
106 "Tag names and content can be edited with `/tags edit`.\n" +
107 "To delete a tag, type `/tags delete <tag name>`.\n" +
108 "To view all tags, type `/tags list`.\n"
109 )
110 .setEmoji("NUCLEUS.LOGO")
111 .setStatus("Danger")
112 ).setTitle("Tags").setDescription("Tag system").setPageId(6)
pineafanad54d752022-04-18 19:01:43 +0100113 ]
pineafane625d782022-05-09 18:04:32 +0100114 let m;
pineafanad54d752022-04-18 19:01:43 +0100115 if (interaction) {
116 m = await interaction.reply({embeds: [
pineafan4edb7762022-06-26 19:21:04 +0100117 new EmojiEmbed()
pineafanad54d752022-04-18 19:01:43 +0100118 .setTitle("Welcome")
119 .setDescription(`One moment...`)
120 .setStatus("Danger")
121 .setEmoji("NUCLEUS.LOADING")
122 ], fetchReply: true, ephemeral: true});
123 } else {
124 m = await c.send({embeds: [
pineafan4edb7762022-06-26 19:21:04 +0100125 new EmojiEmbed()
pineafanad54d752022-04-18 19:01:43 +0100126 .setTitle("Welcome")
127 .setDescription(`One moment...`)
128 .setStatus("Danger")
129 .setEmoji("NUCLEUS.LOADING")
130 ], fetchReply: true });
pineafane625d782022-05-09 18:04:32 +0100131 }
pineafanad54d752022-04-18 19:01:43 +0100132 let page = 0;
133
134 let f = async (component) => {
135 return (component.member as Discord.GuildMember).permissions.has("MANAGE_GUILD");
136 }
137
pineafanea063042022-05-19 19:08:44 +0100138 let selectPaneOpen = false;
139
pineafanad54d752022-04-18 19:01:43 +0100140 while (true) {
pineafanea063042022-05-19 19:08:44 +0100141 let selectPane = []
142
143 if (selectPaneOpen) {
144 let options = [];
145 pages.forEach(embed => {
146 options.push(new SelectMenuOption({
147 label: embed.title,
148 value: embed.pageId.toString(),
149 description: embed.description || "",
150 }))
151 })
152 selectPane = [new MessageActionRow().addComponents([
153 new Discord.MessageSelectMenu()
154 .addOptions(options)
155 .setCustomId("page")
156 .setMaxValues(1)
157 .setPlaceholder("Choose a page...")
158 ])]
159 }
pineafan6702cef2022-06-13 17:52:37 +0100160 let components = selectPane.concat([new MessageActionRow().addComponents([
161 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
162 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
163 new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1),
164 new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER")
165 ])])
pineafanad54d752022-04-18 19:01:43 +0100166 if (interaction) {
pineafanea063042022-05-19 19:08:44 +0100167 let em = new Discord.MessageEmbed(pages[page].embed)
pineafan34369e62022-05-18 16:52:37 +0100168 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
pineafanad54d752022-04-18 19:01:43 +0100169 await interaction.editReply({
pineafan34369e62022-05-18 16:52:37 +0100170 embeds: [em],
pineafan6702cef2022-06-13 17:52:37 +0100171 components: components
pineafanad54d752022-04-18 19:01:43 +0100172 });
173 } else {
pineafanea063042022-05-19 19:08:44 +0100174 let em = new Discord.MessageEmbed(pages[page].embed)
175 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
pineafanad54d752022-04-18 19:01:43 +0100176 await m.edit({
pineafanea063042022-05-19 19:08:44 +0100177 embeds: [em],
pineafan6702cef2022-06-13 17:52:37 +0100178 components: components,
pineafanad54d752022-04-18 19:01:43 +0100179 fetchReply: true
180 });
181 }
182 let i
183 try {
pineafanc6158ab2022-06-17 16:34:07 +0100184 i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 300000});
pineafanad54d752022-04-18 19:01:43 +0100185 } catch(e) { break }
186 i.deferUpdate()
187 if (i.component.customId == "left") {
188 if (page > 0) page--;
pineafanea063042022-05-19 19:08:44 +0100189 selectPaneOpen = false;
pineafanad54d752022-04-18 19:01:43 +0100190 } else if (i.component.customId == "right") {
191 if (page < pages.length - 1) page++;
pineafanea063042022-05-19 19:08:44 +0100192 selectPaneOpen = false;
193 } else if (i.component.customId == "select") {
194 selectPaneOpen = !selectPaneOpen;
195 } else if (i.component.customId == "page") {
196 page = parseInt(i.values[0]);
197 selectPaneOpen = false;
198 } else {
pineafanad54d752022-04-18 19:01:43 +0100199 if (interaction) {
pineafanea063042022-05-19 19:08:44 +0100200 let em = new Discord.MessageEmbed(pages[page].embed)
pineafan34369e62022-05-18 16:52:37 +0100201 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
202 interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
203 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
pineafanea063042022-05-19 19:08:44 +0100204 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(true),
pineafan34369e62022-05-18 16:52:37 +0100205 new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
206 new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
207 ])], fetchReply: true});
pineafanad54d752022-04-18 19:01:43 +0100208 } else {
209 m.delete();
210 }
211 return;
pineafanad54d752022-04-18 19:01:43 +0100212 }
213 }
214 if (interaction) {
pineafan34369e62022-05-18 16:52:37 +0100215 let em = new Discord.MessageEmbed(pages[page])
216 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
pineafanad54d752022-04-18 19:01:43 +0100217 await interaction.editReply({
pineafan34369e62022-05-18 16:52:37 +0100218 embeds: [em],
pineafanad54d752022-04-18 19:01:43 +0100219 components: [new MessageActionRow().addComponents([
220 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
pineafanea063042022-05-19 19:08:44 +0100221 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
pineafanad54d752022-04-18 19:01:43 +0100222 new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
223 new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
224 ])]
225 });
226 } else {
pineafan34369e62022-05-18 16:52:37 +0100227 let em = new Discord.MessageEmbed(pages[page])
228 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
pineafanad54d752022-04-18 19:01:43 +0100229 await m.edit({
pineafan34369e62022-05-18 16:52:37 +0100230 embeds: [em],
pineafanad54d752022-04-18 19:01:43 +0100231 components: [new MessageActionRow().addComponents([
232 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
pineafanea063042022-05-19 19:08:44 +0100233 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
pineafanad54d752022-04-18 19:01:43 +0100234 new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
235 new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
236 ])]
237 });
238 }
239}