Skip to content

Commit d37a3aa

Browse files
authored
Add /thanks (#79)
While I work on the dual NLP and slash-command activation of skills, this will start as a slash command so that it is more prominent.
1 parent 5ea7fe9 commit d37a3aa

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

glyph-bot/src/main/kotlin/Glyph.kt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import org.yttr.glyph.bot.ai.AIAgent
3535
import org.yttr.glyph.bot.ai.dialogflow.Dialogflow
3636
import org.yttr.glyph.bot.messaging.ComplianceListener
3737
import org.yttr.glyph.bot.messaging.MessagingDirector
38+
import org.yttr.glyph.bot.messaging.ThanksListener
3839
import org.yttr.glyph.bot.messaging.quickview.QuickviewDirector
3940
import org.yttr.glyph.bot.presentation.BotList
4041
import org.yttr.glyph.bot.presentation.ServerDirector
@@ -43,12 +44,7 @@ import org.yttr.glyph.bot.skills.SkillDirector
4344
import org.yttr.glyph.bot.skills.config.ConfigDirector
4445
import org.yttr.glyph.bot.skills.config.ServerConfigSkill
4546
import org.yttr.glyph.bot.skills.creator.ChangeStatusSkill
46-
import org.yttr.glyph.bot.skills.moderation.AuditingDirector
47-
import org.yttr.glyph.bot.skills.moderation.BanSkill
48-
import org.yttr.glyph.bot.skills.moderation.GuildInfoSkill
49-
import org.yttr.glyph.bot.skills.moderation.KickSkill
50-
import org.yttr.glyph.bot.skills.moderation.PurgeSkill
51-
import org.yttr.glyph.bot.skills.moderation.UserInfoSkill
47+
import org.yttr.glyph.bot.skills.moderation.*
5248
import org.yttr.glyph.bot.skills.play.DoomsdayClockSkill
5349
import org.yttr.glyph.bot.skills.play.EphemeralSaySkill
5450
import org.yttr.glyph.bot.skills.play.RankSkill
@@ -57,13 +53,7 @@ import org.yttr.glyph.bot.skills.roles.RoleListSkill
5753
import org.yttr.glyph.bot.skills.roles.RoleSetSkill
5854
import org.yttr.glyph.bot.skills.roles.RoleUnsetSkill
5955
import org.yttr.glyph.bot.skills.starboard.StarboardDirector
60-
import org.yttr.glyph.bot.skills.util.FallbackSkill
61-
import org.yttr.glyph.bot.skills.util.FeedbackSkill
62-
import org.yttr.glyph.bot.skills.util.HelpSkill
63-
import org.yttr.glyph.bot.skills.util.SnowstampSkill
64-
import org.yttr.glyph.bot.skills.util.SourceSkill
65-
import org.yttr.glyph.bot.skills.util.StatusSkill
66-
import org.yttr.glyph.bot.skills.util.TimeSkill
56+
import org.yttr.glyph.bot.skills.util.*
6757
import org.yttr.glyph.bot.skills.wiki.WikiSkill
6858
import org.yttr.glyph.shared.pubsub.redis.RedisAsync
6959

@@ -164,7 +154,7 @@ object Glyph {
164154
serverDirector, QuickviewDirector(messagingDirector), StatusDirector, StarboardDirector(redis)
165155
)
166156

167-
it.addEventListeners(ComplianceListener)
157+
it.addEventListeners(ComplianceListener, ThanksListener)
168158
}
169159

170160
builder.build()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.yttr.glyph.bot.extensions
2+
3+
import net.dv8tion.jda.api.EmbedBuilder
4+
import net.dv8tion.jda.api.entities.MessageEmbed
5+
6+
/**
7+
* Shorthand for building an embed
8+
*/
9+
fun embedBuilder(builder: EmbedBuilder.() -> Unit): MessageEmbed =
10+
EmbedBuilder().also(builder).build()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.yttr.glyph.bot.messaging
2+
3+
import net.dv8tion.jda.api.events.ReadyEvent
4+
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent
5+
import net.dv8tion.jda.api.hooks.ListenerAdapter
6+
import net.dv8tion.jda.api.interactions.commands.build.CommandData
7+
import org.yttr.glyph.bot.extensions.embedBuilder
8+
import org.yttr.glyph.shared.readMarkdown
9+
10+
object ThanksListener : ListenerAdapter() {
11+
private const val COMMAND_NAME = "thanks"
12+
13+
override fun onReady(event: ReadyEvent) {
14+
val commandData = CommandData(COMMAND_NAME, "Special thanks to our sponsors.")
15+
16+
event.jda.upsertCommand(commandData).queue()
17+
}
18+
19+
private val content = this::class.java.classLoader.readMarkdown("thanks.md")
20+
21+
override fun onSlashCommand(event: SlashCommandEvent) {
22+
if (event.commandPath == COMMAND_NAME) {
23+
val embed = embedBuilder {
24+
setTitle("Acknowledgements")
25+
setDescription(content)
26+
}
27+
28+
event.replyEmbeds(embed).setEphemeral(true).queue()
29+
}
30+
}
31+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*We would like to express our gratitude to our sponsors. Their generous support helps pay for the servers that keep this project running.*
2+
3+
- **[IBP-0](https://github.com/IBP-0)**
4+
5+
[Become a GitHub Sponsor](https://github.com/sponsors/yttrian) - [Buy me a Ko-Fi](https://ko-fi.com/throudin)

0 commit comments

Comments
 (0)