init: Initial commit
This commit is contained in:
commit
0fa9a44640
25 changed files with 767 additions and 0 deletions
14
bot/build.gradle.kts
Normal file
14
bot/build.gradle.kts
Normal file
|
@ -0,0 +1,14 @@
|
|||
plugins {
|
||||
kotlin("jvm") version "2.0.0"
|
||||
application
|
||||
}
|
||||
|
||||
group = "io.github.null2264.tsukumogami.bot"
|
||||
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("$group.MainKt")
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package io.github.null2264.tsukumogami.bot
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
import io.github.null2264.tsukumogami.bot.core.di.appModule
|
||||
import io.github.null2264.tsukumogami.bot.core.module.DeveloperModule
|
||||
import io.github.null2264.tsukumogami.bot.core.module.GeneralModule
|
||||
import io.github.null2264.tsukumogami.bot.core.Bot
|
||||
import org.koin.core.context.GlobalContext.startKoin
|
||||
|
||||
suspend fun main() {
|
||||
|
||||
startKoin {
|
||||
modules(appModule)
|
||||
}
|
||||
|
||||
Bot {
|
||||
Logger.setTag("Tsukumogami")
|
||||
|
||||
token = System.getenv("DISCORD_TOKEN")
|
||||
|
||||
prefixes("src!", "mm!") // mm! for backwards compatibility
|
||||
|
||||
extensions(::DeveloperModule, ::GeneralModule)
|
||||
}.start()
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package io.github.null2264.tsukumogami.bot.core
|
||||
|
||||
import io.github.null2264.tsukumogami.core.AbstractBot
|
||||
import io.github.null2264.tsukumogami.core.BotConfigurator
|
||||
|
||||
class Bot(block: BotConfigurator.() -> Unit = {}) : AbstractBot(block)
|
|
@ -0,0 +1,7 @@
|
|||
package io.github.null2264.tsukumogami.bot.core.di
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
val appModule = module {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package io.github.null2264.tsukumogami.bot.core.module
|
||||
|
||||
import io.github.null2264.tsukumogami.core.module.annotation.Command
|
||||
import io.github.null2264.tsukumogami.core.Context
|
||||
import io.github.null2264.tsukumogami.core.module.BotModule
|
||||
|
||||
class DeveloperModule : BotModule("Developer", "Only for developers") {
|
||||
|
||||
@Command(
|
||||
name="poweroff",
|
||||
description="Turn the bot off",
|
||||
)
|
||||
private suspend fun shutdown(ctx: Context) {
|
||||
ctx.reply("Shutting Down...", mentionsAuthor = true)
|
||||
bot?.stop()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package io.github.null2264.tsukumogami.bot.core.module
|
||||
|
||||
import io.github.null2264.tsukumogami.core.module.annotation.Command
|
||||
import io.github.null2264.tsukumogami.core.Context
|
||||
import io.github.null2264.tsukumogami.core.module.BotModule
|
||||
import kotlinx.datetime.Clock
|
||||
|
||||
class GeneralModule : BotModule("General", "idk") {
|
||||
|
||||
@Command(description = "Ping the bot!")
|
||||
private suspend fun ping(ctx: Context) {
|
||||
val startTime = Clock.System.now()
|
||||
ctx.typing()
|
||||
val endTime = Clock.System.now()
|
||||
ctx.send("Pong! ${endTime.toEpochMilliseconds() - startTime.toEpochMilliseconds()}ms")
|
||||
}
|
||||
|
||||
@Command("test")
|
||||
private suspend fun differentName(ctx: Context) {
|
||||
ctx.send("Hello World! ${ctx.author}")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue