GithubHelp home page GithubHelp logo

fw4hre0xxq / bot-kt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 5ht2/bot-kt

0.0 0.0 0.0 163 KB

Moderation bot for the KAMI Blue Discord

Home Page: https://kamiblue.org/discord

License: ISC License

Kotlin 98.05% Shell 1.95%

bot-kt's Introduction

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'

bot-kt's People

Contributors

5ht2 avatar zeroeightysix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.