|
| 1 | +import { InteractionCallbackTypes, MessageComponentButtonStyles, MessageFlags } from "detritus-client/lib/constants"; |
| 2 | +import { InteractionContext } from "detritus-client/lib/interaction"; |
| 3 | +import { InteractionEditOrRespond } from "detritus-client/lib/structures"; |
| 4 | +import { ComponentActionData, ComponentButton, ComponentContext, ComponentSelectMenu, Embed, InteractionModal } from "detritus-client/lib/utils"; |
| 5 | + |
| 6 | +const topicList = [ |
| 7 | + { |
| 8 | + label: "About this bot", |
| 9 | + value: "about", |
| 10 | + }, |
| 11 | + { |
| 12 | + label: "Changelog", |
| 13 | + value: "changelog", |
| 14 | + }, |
| 15 | + { |
| 16 | + label: "Custom Roles", |
| 17 | + value: "customrole", |
| 18 | + }, |
| 19 | + { |
| 20 | + label: "VC Notifications", |
| 21 | + value: "vcnotify", |
| 22 | + }, |
| 23 | + { |
| 24 | + label: "Server Icon Hue Changing", |
| 25 | + value: "hue", |
| 26 | + }, |
| 27 | + { |
| 28 | + label: "Misc.", |
| 29 | + value: "misc", |
| 30 | + }, |
| 31 | +]; |
| 32 | + |
| 33 | +export class HelpSelectMenuComponent extends ComponentSelectMenu { |
| 34 | + embed: Embed; |
| 35 | + admin: boolean; |
| 36 | + |
| 37 | + constructor(ctx: InteractionContext, data?: ComponentActionData) { |
| 38 | + super(data); |
| 39 | + |
| 40 | + this.customId = "helpSelect"; |
| 41 | + this.embed = new Embed({ |
| 42 | + author: { |
| 43 | + icon_url: ctx.me!.avatarUrl, |
| 44 | + name: ctx.me!.username, |
| 45 | + }, |
| 46 | + title: "Help", |
| 47 | + description: `Select a topic below. *Some information can only be seen by admins because it isn't relevant to normal users.*`, |
| 48 | + }); |
| 49 | + |
| 50 | + this.admin = ctx.member!.canAdministrator; |
| 51 | + |
| 52 | + this.maxValues = 1; |
| 53 | + this.placeholder = "Select a topic..."; |
| 54 | + |
| 55 | + topicList.forEach((element) => { |
| 56 | + this.createOption(element); |
| 57 | + }); |
| 58 | + } |
| 59 | + |
| 60 | + run(ctx: ComponentContext) { |
| 61 | + const values = ctx.data.values ?? []; |
| 62 | + const response: InteractionEditOrRespond = { |
| 63 | + flags: MessageFlags.EPHEMERAL, |
| 64 | + embed: this.embed, |
| 65 | + }; |
| 66 | + |
| 67 | + if (this.embed.fields) this.embed.fields.clear(); |
| 68 | + |
| 69 | + if (values.length === 0) { |
| 70 | + return ctx.editOrRespond(response); |
| 71 | + } else { |
| 72 | + switch (values[0]) { |
| 73 | + case "about": |
| 74 | + response.embed = this.about(); |
| 75 | + break; |
| 76 | + |
| 77 | + case "changelog": |
| 78 | + response.embed = this.changelog(); |
| 79 | + break; |
| 80 | + |
| 81 | + case "customrole": |
| 82 | + response.embed = this.customrole(); |
| 83 | + break; |
| 84 | + |
| 85 | + case "vcnotify": |
| 86 | + response.embed = this.vcnotify(); |
| 87 | + break; |
| 88 | + |
| 89 | + case "hue": |
| 90 | + response.embed = this.hue(); |
| 91 | + break; |
| 92 | + |
| 93 | + case "misc": |
| 94 | + response.embed = this.misc(); |
| 95 | + break; |
| 96 | + |
| 97 | + default: |
| 98 | + break; |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + return ctx.editOrRespond(response); |
| 103 | + } |
| 104 | + |
| 105 | + private about(): Embed { |
| 106 | + this.embed.setTitle("Help: About this bot"); |
| 107 | + this.embed.setDescription( |
| 108 | + `This bot was developed by <@249880389160665089> for small, private servers (max. 50 members maybe). It mainly adds more utilities and customization for users, check out the topics to see what it can do. |
| 109 | +It isn't a single, publicly available bot which anyone can invite, it has to be self hosted and only supports one server. |
| 110 | +\nIt's open source under the name "legendary-palm-tree": [GitHub](https://github.com/EleosOS/legendary-palm-tree)` |
| 111 | + ); |
| 112 | + |
| 113 | + return this.embed; |
| 114 | + } |
| 115 | + |
| 116 | + private changelog(): Embed { |
| 117 | + this.embed.setTitle("Help: Changelog"); |
| 118 | + this.embed.setDescription( |
| 119 | + `See what changed with each major version. Many versions only had internal changes which aren't listed. *Some listed changes can only be seen by admins.*` |
| 120 | + ); |
| 121 | + |
| 122 | + this.embed.addField( |
| 123 | + "Version 1.1", |
| 124 | + `All important info on commands has been moved into the slash command UI. |
| 125 | +\nAll commands have been reworked into slash commands, that means the prefix \`os\` has also been retired. Slash commands are available in every channel, even if the bot can't see it. |
| 126 | +\nMost, if not all command responses are now "ephemeral", they will only show up for you personally. |
| 127 | +\n\`role\` - Role creation/editing has been moved into the subcommand \`/role create\`. |
| 128 | +\n\`role info\` - Has been renamed to \`/role inspect\`. You can now inspect the role of every user, not just your own.` |
| 129 | + ); |
| 130 | + |
| 131 | + this.embed.addField( |
| 132 | + "Version 1.2", |
| 133 | + `Custom Roles now stay at the bottom of the roles list. |
| 134 | +${this.admin ? "\n*Admins can now overwrite the stored server icon hue value without actually changing the hue.*" : ""}` |
| 135 | + ); |
| 136 | + |
| 137 | + this.embed.addField( |
| 138 | + "Version 1.3", |
| 139 | + `Admins can now change the schedule of hue changes and how much it should change each time. |
| 140 | +\nHue changes will be cancelled if the server icon is animated. |
| 141 | +\nThe bot can now send a message when a member leaves the server. |
| 142 | +${this.admin ? "\n*There are now many more usage logs available.*" : ""}` |
| 143 | + ); |
| 144 | + |
| 145 | + this.embed.addField( |
| 146 | + "Version 2", |
| 147 | + `VC Notifications have been added. |
| 148 | +\n\`/help\` - Has been reworked with a select menu and now includes descriptions of features. |
| 149 | +\n\`/role\` - The parent command has been renamed to \`/customrole\`. |
| 150 | +\nCustom Roles are now automatically deleted when their user leaves the server. |
| 151 | +${this.admin ? "\n*Command usage logs have been improved to include the used arguments.*" : ""}` |
| 152 | + ); |
| 153 | + |
| 154 | + return this.embed; |
| 155 | + } |
| 156 | + |
| 157 | + private customrole(): Embed { |
| 158 | + this.embed.setTitle("Help: Custom Roles"); |
| 159 | + this.embed.setDescription(`Custom roles are roles that you can create yourself. You decide the name and color. One user can only have one custom role. |
| 160 | +${this.admin ? "\n*New custom roles will always be on the bottom of the role list among other custom roles. Make sure other roles above them don't override the color!*" : ""}`); |
| 161 | + |
| 162 | + this.embed.addField( |
| 163 | + "Commands", |
| 164 | + `\`/customrole create (hex) (rolename)\` - Creates a new custom role or edits the current custom role. |
| 165 | +hex: A valid hex color code, for example "#4c88ff" (# included). |
| 166 | +rolename: The name that your role should have, can only be max. 100 characters long. |
| 167 | +\n\`/customrole remove\` - Removes your custom role. |
| 168 | +\n\`/customrole inspect (user)\` - Shows information on the custom role of the selected user, like name and color.` |
| 169 | + ); |
| 170 | + |
| 171 | + if (this.admin) { |
| 172 | + this.embed.addField("Admin - Logging", `The bot can log when a custom role is created or removed, including the user and information on the role.`); |
| 173 | + } |
| 174 | + |
| 175 | + return this.embed; |
| 176 | + } |
| 177 | + |
| 178 | + private vcnotify(): Embed { |
| 179 | + this.embed.setTitle("Help: VC Notifications"); |
| 180 | + this.embed |
| 181 | + .setDescription(`The bot can send you a message when a specific user joins a voice channel (that the bot can see). You can toggle a notification on each user with both a slash command and through the context menu of a user. |
| 182 | +${this.admin ? "\n*❗ The host of the bot needs to configure in which channel notifications should be sent in, otherwise this feature will not work!*" : ""}`); |
| 183 | + |
| 184 | + this.embed.addField("Context Menu", `Right click a user, under Apps select "Toggle VC Notification". You will see a confirmation message.`); |
| 185 | + |
| 186 | + this.embed.addField("Quick Toggle Button", `Messages of this feature include a button with which a VC notification can quickly be toggled again.`); |
| 187 | + |
| 188 | + this.embed.addField( |
| 189 | + "Commands", |
| 190 | + `\`/vcnotify toggle (user)\` - Toggle a VC notification on the selected user. |
| 191 | +\n\`/vcnotify list\` - Shows a list of all users that you'll be notified for.` |
| 192 | + ); |
| 193 | + |
| 194 | + if (this.admin) { |
| 195 | + this.embed.addField("Admin - Logging", `The bot can log when a VC notification is set and when one is triggered, including the related users.`); |
| 196 | + } |
| 197 | + |
| 198 | + return this.embed; |
| 199 | + } |
| 200 | + |
| 201 | + private hue(): Embed { |
| 202 | + this.embed.setTitle("Help: Server Icon Hue Changing"); |
| 203 | + this.embed |
| 204 | + .setDescription(`The bot can automatically change the hue of the server icon at a set schedule. Admins can set the schedule and by how many degrees the hue should change. The hue can also be changed manually. |
| 205 | +❗ Animated server icons are not supported due to technical limitations. The bot will cancel any hue changes and send warnings if it detects that the server icon is animated. |
| 206 | +\nHues are circular, meaning any amounts or hues specified are between 0° and 360°.`); |
| 207 | + |
| 208 | + this.embed.addField( |
| 209 | + "Scheduling", |
| 210 | + `Scheduling is done with cron expressions. The standard schedule is "0 0 * * *" (At 12 am). [Cron Expression Generator by crontabkit.com](https://crontabkit.com/crontab-expression-generator) |
| 211 | +❗ Do not change the icon often! A schedule of e.g. multiple times per hour should be avoided!` |
| 212 | + ); |
| 213 | + |
| 214 | + this.embed.addField( |
| 215 | + "Commands", |
| 216 | + `\`/hue change (amount)\` - Changes the server icon hue. |
| 217 | +amount: How much the hue should change. |
| 218 | +\n\`/hue overwrite (amount)\` - Overwrite the stored hue, for example in case a new server icon was uploaded. |
| 219 | +\n\`/hue step schedule (cronexpression)\` - Sets a new schedule at which the hue will be automatically changed, see "Scheduling". |
| 220 | +\n\`/hue step size (amount) - Sets how much the hue should be automatically changed.\`` |
| 221 | + ); |
| 222 | + |
| 223 | + if (this.admin) { |
| 224 | + this.embed.addField("Admin - Logging", `The bot can log when the hue or settings get changed, including old and new values.`); |
| 225 | + } |
| 226 | + |
| 227 | + return this.embed; |
| 228 | + } |
| 229 | + |
| 230 | + private misc(): Embed { |
| 231 | + this.embed.setTitle("Help: Miscellaneous"); |
| 232 | + this.embed.setDescription(null); |
| 233 | + |
| 234 | + this.embed.addField( |
| 235 | + "Commands", |
| 236 | + `\`/help\` - You're looking at it right now! |
| 237 | +\n\`/ping\` - Pong! |
| 238 | +\n\`/purge (amount)\` - Deletes the specified amount of messages, between 2 and 100 messages at a time.` |
| 239 | + ); |
| 240 | + |
| 241 | + this.embed.addField("User Left Messages", `The bot can be set up to send a message in a specific channel when a user leaves the server.`); |
| 242 | + |
| 243 | + this.embed.addField("Ratelimits", `Some commands have different ratelimits and will be cancelled if used too much.`); |
| 244 | + |
| 245 | + this.embed.addField( |
| 246 | + "Permissions", |
| 247 | + `The bot needs the "Manage Server", "Manage Messages" and "Manage Roles" permissions. Certain commands that require them will cancel if the bot is missing them. |
| 248 | +Users are considered admins if they have the "Administrator" permission. Admin commands will cancel if the user doesn't have permission to use them. |
| 249 | +\nDiscord is currently working on introducing a new, more customizable permission system, so this might change.` |
| 250 | + ); |
| 251 | + |
| 252 | + if (this.admin) { |
| 253 | + this.embed.addField( |
| 254 | + "Admin - Logging", |
| 255 | + `The bot can be set up to log anything related to it, like e.g. command usage. Logs usually include additional information like the arguments used with a command. |
| 256 | +\nLogging is done through Webhooks, so you can decide where these logs should go. They also however need to be set up by the host in the bot configuration.` |
| 257 | + ); |
| 258 | + |
| 259 | + this.embed.addField("Admin - Host", "Please regularly restart the bot and the machine it's hosted on, to avoid errors and degrading."); |
| 260 | + } |
| 261 | + |
| 262 | + return this.embed; |
| 263 | + } |
| 264 | +} |
0 commit comments