|
1 | 1 | package org.yttr.glyph.bot.modules |
2 | 2 |
|
3 | | -import dev.minn.jda.ktx.events.onCommand |
4 | | -import dev.minn.jda.ktx.interactions.commands.slash |
5 | | -import dev.minn.jda.ktx.messages.Embed |
6 | | -import dev.minn.jda.ktx.messages.reply_ |
7 | | -import net.dv8tion.jda.api.JDA |
| 3 | +import net.dv8tion.jda.api.EmbedBuilder |
| 4 | +import net.dv8tion.jda.api.components.actionrow.ActionRow |
| 5 | +import net.dv8tion.jda.api.components.buttons.Button |
| 6 | +import net.dv8tion.jda.api.components.buttons.ButtonStyle |
| 7 | +import net.dv8tion.jda.api.entities.emoji.Emoji |
8 | 8 | import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent |
9 | | -import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction |
| 9 | +import net.dv8tion.jda.api.interactions.commands.build.Commands |
| 10 | +import org.yttr.glyph.bot.Resources |
| 11 | +import org.yttr.glyph.bot.jda.buildReply |
10 | 12 |
|
11 | | -class HelpModule : Module { |
12 | | - override fun register(jda: JDA, commands: CommandListUpdateAction) { |
13 | | - commands.slash(name = "help", description = "Get help using Glyph") |
14 | | - |
15 | | - jda.onCommand(name = "help") { event -> |
16 | | - help(event) |
17 | | - } |
| 13 | +class HelpModule : Module() { |
| 14 | + override fun register() { |
| 15 | + onCommand("help") { event -> help(event) } |
18 | 16 | } |
19 | 17 |
|
| 18 | + override fun commands() = listOf( |
| 19 | + Commands.slash("help", "Get help using Glyph") |
| 20 | + ) |
| 21 | + |
20 | 22 | fun help(event: GenericCommandInteractionEvent) { |
21 | 23 | val name = event.jda.selfUser.name |
22 | | - val embed = Embed { |
23 | | - title = "Help" |
24 | | - color = EMBED_COLOR |
25 | | - } |
26 | 24 |
|
27 | | - event.reply_(embeds = listOf(embed), ephemeral = true).queue() |
| 25 | + event.buildReply { |
| 26 | + ephemeral = true |
| 27 | + |
| 28 | + embeds += EmbedBuilder() |
| 29 | + .setTitle("$name Help") |
| 30 | + .setColor(EMBED_COLOR) |
| 31 | + .setDescription(Resources.readText("help.md").format(name)) |
| 32 | + .build() |
| 33 | + |
| 34 | + components += ActionRow.of( |
| 35 | + linkButton("https://glyph.yttr.org/skills", "Skills", "🕺"), |
| 36 | + linkButton("https://glyph.yttr.org/config", "Configure", "⚙️"), |
| 37 | + linkButton("https://ko-fi.com/throudin", "Buy me a Ko-fi", "☕") |
| 38 | + ) |
| 39 | + }.queue() |
28 | 40 | } |
29 | 41 |
|
30 | 42 | companion object { |
31 | 43 | private const val EMBED_COLOR = 0x4687E5 |
| 44 | + |
| 45 | + private fun linkButton(url: String, label: String, emoji: String) = |
| 46 | + Button.of(ButtonStyle.LINK, url, label, Emoji.fromUnicode(emoji)) |
32 | 47 | } |
33 | 48 | } |
0 commit comments