This repository contains a basic KordEx example bot for you to use as a template for your own KordEx bots. This includes the following:
- A basic extension that allows you to slap other people, using both message commands and slash commands
- A basic bot configuration that enables slash commands and shows you how to conditionally provide a different message command prefix for different guilds
- A Gradle Kotlin build script that makes use of the Kotlin Discord public maven repo, the new JVM IR compiler, Detekt for linting (with a fairly strict configuration), and a Git commit hook plugin that runs Detekt when you make a commit
- GitHub CI scripts that build the bot and publish its artefacts
- A reasonable
.gitignorefile, including one in the.ideafolder that ignores files that shouldn't be committed - if you're using IDEA yourself, you should install the Ignore plugin to handle changes to this for you - A Groovy-based Logback config, so you have reasonable logging out of the gate
- A Gradle wrapper
- The
.ymlfiles in.github/are used to configure GitHub apps. If you're not using them, you can remove them. - The provided
LICENSEfile contains The Unlicense, which makes this repository public domain. You'll probably want to change this - we suggest looking at Choose a License if you're not sure where to start. - In the
build.gradle.kts:- Set the
groupandversionproperties as appropriate - If you're not using this to test KordEx builds, you can remove the
mavenLocal()from therepositoriesblock - In the
applicationandtasks.jarblocks, update the main class path/name as appropriate - To target a newer/older Java version, change the options in the
KotlinCompileconfiguration andjavablocks
- Set the
- In the
settings.gradle.kts, update the name of the root project as appropriate. - The bundled Detekt config is pretty strict. You can check over
detekt.ymlif you want to change it. - The Logback configuration is in
src/main/resources/logback.groovy. If the logging setup doesn't suit, you can change it there.
App.ktincludes a basic bot which uses a hardcoded guild ID and gets the bot's token from theTOKENenvironment variable. Update the guild ID to match your test server's ID. This file also includes some example code that shows one potential way of providing different command prefixes for different servers.TestExtension.ktincludes a simple example extension that creates aslapcommand. This command works as both a message command and slash command, and allows you to slap other users with whatever you wish, defaulting to alarge, smelly trout.
To test the bot, simply update the TEST_SERVER_ID variable in App.kt to your testing server's ID, and run the bot
with the TOKEN environment variable set to a Discord bot token.