Skip to content

Commit

Permalink
Improved some things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laxystem committed Dec 5, 2023
1 parent 98a5156 commit 4f0fec0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/main/kotlin/quest/laxla/supertrouper/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package quest.laxla.supertrouper

import com.kotlindiscord.kord.extensions.ExtensibleBot
import com.kotlindiscord.kord.extensions.utils.env
import dev.kord.common.entity.Snowflake
import kotlinx.coroutines.runBlocking

private val token = env("token")
Expand All @@ -10,11 +11,11 @@ val officialServer = env("official_server")
fun main() = runBlocking {
ExtensibleBot(token) {
extensions {
add(::AboutExtension)
add(::MaintenanceExtension)
}

applicationCommands {
defaultGuild(officialServer)
defaultGuild(Snowflake(officialServer))
}
}.start()
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
package quest.laxla.supertrouper

import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import dev.kord.common.entity.Permission
import dev.kord.common.entity.Snowflake

class AboutExtension : Extension() {
override val name: String
get() = "about"

class MaintenanceExtension : TrouperExtension() {
override suspend fun setup() {
ephemeralSlashCommand {
name = "about"

action {
respond {
//language=Markdown
content = "Hey! This is a test command. It's powered by *magic*:sparkles:"
}
}
}

publicSlashCommand {
name = "stop"
description = "WARNING: Stops the bot completely."
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/quest/laxla/supertrouper/TrouperExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package quest.laxla.supertrouper

import com.kotlindiscord.kord.extensions.extensions.Extension

abstract class TrouperExtension : Extension() {
final override val name: String = this::class.simpleName!!.substringBeforeLast("Extension")
.replace("([A-Z])".toRegex()) { '-' + it.groups.single()!!.value.lowercase() }.removePrefix("-")
}

0 comments on commit 4f0fec0

Please sign in to comment.