GithubHelp home page GithubHelp logo

5ht2 / bot-kt Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 4.0 1.31 MB

Easy to use Kotlin Discord bot framework

License: ISC License

Kotlin 98.19% Shell 1.53% Dockerfile 0.28%
kordis discord bot-kt discord-bot

bot-kt's Introduction

bot-kt

CodeFactor Docker Action Gradle Action

Why should you use this over other Kotlin bots:

  • Plugin support in the form of Kotlin
  • 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 BotCommand(name = "Example", description = "Example Command")
  • Has a DSL for our own Brigadier-like command system, making creating a command as easy as just writing a few lambdas
  • Has (optional) automatic updating

Contributing

  1. git clone --recurse-submodules https://github.com/l1ving/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

Or without an IDE

  1. git clone https://github.com/l1ving/bot-kt.git
  2. cd bot-kt
  3. ./completeBuild.sh

Note: completeBuild.sh has the optional -s (silent) and --no-lint (don't require ktlint) options, in that order.

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-v1.9.3.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 BotCommand(name = "Example", description = "Example Command).

Look at ExampleCommand for example usage of our Command DSL.

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 bitbuf avatar d1snin avatar not-ivy avatar zeroeightysix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bot-kt's Issues

;roleinfo

Gives information such as

  • color
  • if you have the following permissions (dyno lists useless ones)
    • Audit Log
    • Manage Roles/Server/Channels
    • Kick/Ban
    • Manage messages
    • Mention @ everyone and the such
      Status
  • high council vs lower council vs citizen

;slowmode

Usage: ;slow 30 120

Both numbers in seconds, first one is the slowmode speed and second one is how long it should be applied before removing it

;unslow to remove slowmode in case the bot was restarted during an active slowmode and it doesn't know when to remove it

You should be able to use this if you have manage messages permissions

;lock and ;unlock

Quickly lock all channels during raids.

you should be able to use this if you have manage messages permission

Unban command

I can't believe there isn't command for unbanning people while we have ;ban

Music

Is your feature request related to a problem? Please describe.
Js bot is buggy and everytime it is not disconnected correctly it needs to restart in order to play music again

Describe the solution you'd like
Add music command to kotlin bot

Describe alternatives you've considered
Keep it in the js bot

Additional context
This might help: https://github.com/sedmelluq/LavaPlayer

kotlinx.serialization

Is your feature request related to a problem? Please describe.
Gson is not based and not pog

Describe the solution you'd like
Use kotlinx.serialization.

Describe alternatives you've considered
No :trollface:

Additional context
๐Ÿˆ

Issue viewing is broken

Created by: Living (563138570953687061)

Happened after I refactored discussion api. Share the classes idk lol

@Permission(NAME) annotation

Instead of adding an if (message.hasPermission(NAME)) in every single argument, add an annotation which checks it before even posting the command!

webhooks?

Support custom webhooks. Kinda like discord webhook

Last three fields for the pr's embed broken

Describe the bug
The last three fields for the pr embed doesn't work(IssueCommand).

To Reproduce

  1. Type ;issue <any repo> <pr's num that made changes>

Expected behavior
Expected to list the addition, deletion, commits and changed files correctly.

Screenshots
2020-10-03-11-48-43

Additional context
Maybe its the discussion api's problem? here

Fix userinfo command

Created by: Living (563138570953687061)

I forgot to make the fields for not in guild and in guild the same

;release command

Runs the releaseNightly.sh script. This would probably require kami-blue/client#1087 first?

I think I'd have to save this for the Kotlin bot due to permissions, and the JavaScript bot is meant to be something skrub can freely push to without anybody running the risk of doing something destructive to the server

;issue command bug

Created by: Living (563138570953687061)

Issue Labels / assignees aren't space separated

;whois

Shows username (works with ID when not in the discord), playing / spotify etc status, account creation age, joined server date and time etc

Emotes for ;userinfo

Is your feature request related to a problem? Please describe.
I miss the bot-js emotes.

image
bot-kt, currently

Describe the solution you'd like
I would like to see the emotes back onto ;userinfo like this:

image
bot-js

Port starboard here

Is your feature request related to a problem? Please describe.
js bad

Describe the solution you'd like
port the starboard feature of js bot here

MainKt run function opens invisible window.

When run in the dev environment an invisible window called MainKt is opened, this probably shouldn't happen as it is annoying while testing due to focus switches. (using macOS)

Fix

Created by: Living (563138570953687061)

userinfo command;I forgot to make the fields for not in guild and in guild the same

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.