Skip to content

Commit

Permalink
Add /thanks (#79)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yttrian committed May 18, 2023
1 parent 5ea7fe9 commit d37a3aa
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
18 changes: 4 additions & 14 deletions glyph-bot/src/main/kotlin/Glyph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.yttr.glyph.bot.ai.AIAgent
import org.yttr.glyph.bot.ai.dialogflow.Dialogflow
import org.yttr.glyph.bot.messaging.ComplianceListener
import org.yttr.glyph.bot.messaging.MessagingDirector
import org.yttr.glyph.bot.messaging.ThanksListener
import org.yttr.glyph.bot.messaging.quickview.QuickviewDirector
import org.yttr.glyph.bot.presentation.BotList
import org.yttr.glyph.bot.presentation.ServerDirector
Expand All @@ -43,12 +44,7 @@ import org.yttr.glyph.bot.skills.SkillDirector
import org.yttr.glyph.bot.skills.config.ConfigDirector
import org.yttr.glyph.bot.skills.config.ServerConfigSkill
import org.yttr.glyph.bot.skills.creator.ChangeStatusSkill
import org.yttr.glyph.bot.skills.moderation.AuditingDirector
import org.yttr.glyph.bot.skills.moderation.BanSkill
import org.yttr.glyph.bot.skills.moderation.GuildInfoSkill
import org.yttr.glyph.bot.skills.moderation.KickSkill
import org.yttr.glyph.bot.skills.moderation.PurgeSkill
import org.yttr.glyph.bot.skills.moderation.UserInfoSkill
import org.yttr.glyph.bot.skills.moderation.*
import org.yttr.glyph.bot.skills.play.DoomsdayClockSkill
import org.yttr.glyph.bot.skills.play.EphemeralSaySkill
import org.yttr.glyph.bot.skills.play.RankSkill
Expand All @@ -57,13 +53,7 @@ import org.yttr.glyph.bot.skills.roles.RoleListSkill
import org.yttr.glyph.bot.skills.roles.RoleSetSkill
import org.yttr.glyph.bot.skills.roles.RoleUnsetSkill
import org.yttr.glyph.bot.skills.starboard.StarboardDirector
import org.yttr.glyph.bot.skills.util.FallbackSkill
import org.yttr.glyph.bot.skills.util.FeedbackSkill
import org.yttr.glyph.bot.skills.util.HelpSkill
import org.yttr.glyph.bot.skills.util.SnowstampSkill
import org.yttr.glyph.bot.skills.util.SourceSkill
import org.yttr.glyph.bot.skills.util.StatusSkill
import org.yttr.glyph.bot.skills.util.TimeSkill
import org.yttr.glyph.bot.skills.util.*
import org.yttr.glyph.bot.skills.wiki.WikiSkill
import org.yttr.glyph.shared.pubsub.redis.RedisAsync

Expand Down Expand Up @@ -164,7 +154,7 @@ object Glyph {
serverDirector, QuickviewDirector(messagingDirector), StatusDirector, StarboardDirector(redis)
)

it.addEventListeners(ComplianceListener)
it.addEventListeners(ComplianceListener, ThanksListener)
}

builder.build()
Expand Down
10 changes: 10 additions & 0 deletions glyph-bot/src/main/kotlin/extensions/EmbedBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.yttr.glyph.bot.extensions

import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.MessageEmbed

/**
* Shorthand for building an embed
*/
fun embedBuilder(builder: EmbedBuilder.() -> Unit): MessageEmbed =
EmbedBuilder().also(builder).build()
31 changes: 31 additions & 0 deletions glyph-bot/src/main/kotlin/messaging/ThanksListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.yttr.glyph.bot.messaging

import net.dv8tion.jda.api.events.ReadyEvent
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.dv8tion.jda.api.interactions.commands.build.CommandData
import org.yttr.glyph.bot.extensions.embedBuilder
import org.yttr.glyph.shared.readMarkdown

object ThanksListener : ListenerAdapter() {
private const val COMMAND_NAME = "thanks"

override fun onReady(event: ReadyEvent) {
val commandData = CommandData(COMMAND_NAME, "Special thanks to our sponsors.")

event.jda.upsertCommand(commandData).queue()
}

private val content = this::class.java.classLoader.readMarkdown("thanks.md")

override fun onSlashCommand(event: SlashCommandEvent) {
if (event.commandPath == COMMAND_NAME) {
val embed = embedBuilder {
setTitle("Acknowledgements")
setDescription(content)
}

event.replyEmbeds(embed).setEphemeral(true).queue()
}
}
}
5 changes: 5 additions & 0 deletions glyph-bot/src/main/resources/thanks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*We would like to express our gratitude to our sponsors. Their generous support helps pay for the servers that keep this project running.*

- **[IBP-0](https://github.com/IBP-0)**

[Become a GitHub Sponsor](https://github.com/sponsors/yttrian) - [Buy me a Ko-Fi](https://ko-fi.com/throudin)

0 comments on commit d37a3aa

Please sign in to comment.