Skip to content
forked from 5HT2/bot-kt

Moderation bot for the KAMI Blue Discord

License

Notifications You must be signed in to change notification settings

fw4hre0xxq/bot-kt

 
 

Repository files navigation

bot-kt

GitHub All Releases Discord

The moderation bot for KAMI Blue's Discord, written in Kotlin for reliability.

Why should you use this over other Kotlin bots:

  • Extremely easy to add your own commands
  • Really easy to configure
  • Entirely modular, including config types and commands
  • Config types support providing a URL instead of a file name, allowing you to load configurations remotely
  • Command registration is automatic, just create an object which extends Command("commandName")
  • Uses Brigadier as a command system, making creating a command as easy as just writing a few lambdas
  • Has (optional) automatic updating

Contributing

  1. git clone [email protected]:kami-blue/bot-kt.git
  2. In Intellij IDEA select File -> New -> Project from existing sources
  3. Import the build.gradle file
  4. Wait for the Gradle import to finish

Usage

Create your config/auth.json like below. Generate githubToken with repo:status and public_repo access checked here and you can get your bot token here.

The githubToken is only required if you want to use any of the Github commands, such as ;issue

{
    "botToken": "token",
    "githubToken": "token"
}
`user.json` example

All elements are optional. statusMessageType defaults to "Playing".

{
    "autoUpdate": "true",
    "primaryServerId": "573954110454366214",
    "startUpChannel": "dev-bot",
    "statusMessage": "out for raids",
    "statusMessageType": "3"
}

Running

Running in Intellij

Hit the Run ▶️ button in the top right of your IDE, to the right of MainKt.

If the MainKt run configuration isn't imported automatically in Intellij, try File -> Close Project and then reopen the project.

If that still does not help, Hit Add Configuration in the upper right of your IDE, select the MainKt configuration on the left and hit Ok.

Running prebuilt binaries

java -jar bot-kt-1.1.0.jar

Disabling update checking

If you're working on your own fork or just don't care for updates for some reason, you can create a file named noUpdateCheck in the same directory where you run the bot from.

If you're on Windows, please make sure you don't have .txt at the end, as Windows hides file extensions by default.

Creating a new command

Create an object in the commands package that extends Command("yourCommandName"). Look at ExampleCommand for example usage of our Brigadier DSL wrapper.

Creating a new config type

Simply create a new dataclass inside FileManager, and register it inside ConfigType.

Here's an example:

object FileManager {
    var exampleConfigData: ExampleConfig? = null
}
/**
 * [someValue] is a value from inside your example.json
 */
data class ExampleConfig(val someValue: String)
/**
 * Note that [configPath] can also be an https URL, but you will not be able to write the config if it's a remote URL. This is fine for remotely configuring a setting.
 */
enum class ConfigType(val configPath: String, var data: Any?, val clazz: Class<*>) {
    EXAMPLE("example.json", exampleConfigData, ExampleConfig::class.java);
}

Storing the value: (can be a remote file online or just a local file)

{
    "someValue": "This is a String value for my ExampleConfig"
}

Reading the value:

val config = FileManager.readConfigSafe<ExampleConfig>(ConfigType.EXAMPLE, false) // setting reload to true instead of false will forcefully load it from the URL / memory instead of returning the cached version

config?.someValue?.let {
    println("Value is '$it'")
}

// > Value is 'This is a String value for my ExampleConfig'

About

Moderation bot for the KAMI Blue Discord

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 98.0%
  • Shell 2.0%