Skip to content
/ Kotlin-JDA-Base Public template

A JDA Starter Project in Kotlin with a few features.

License

Notifications You must be signed in to change notification settings

Monmcgt/Kotlin-JDA-Base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin JDA Base

A JDA Starter Project in Kotlin with a few features.

Important Classes / Packages

How to use

Example

without command options (Ping.kt)

package me.monmcgt.code.commands.impl

import me.monmcgt.code.commands.CommandAbstract
import me.monmcgt.code.commands.CommandInfo
import me.monmcgt.code.commands.RegisterCommand

@RegisterCommand
@CommandInfo(name = "ping", description = "responds with pong")
class Ping : CommandAbstract() {
    override fun onSlashCommandInteraction() {
        sendEmphemralMessage("Pong!")
    }
}


without command options (UserAvatar.kt)

package me.monmcgt.code.commands.impl

import me.monmcgt.code.commands.CommandAbstract
import me.monmcgt.code.commands.CommandInfo
import me.monmcgt.code.commands.RegisterCommand

@RegisterCommand
@CommandInfo(name = "useravatar", description = "Get the avatar of a user")
class UserAvatar : CommandAbstract() {
    override fun onSlashCommandInteraction() {
        val member = event.member
        if (member == null) {
            sendEmphemralMessage("Something went wrong, please try again later")
            return
        }
        sendEmphemralMessage(member.user.effectiveAvatarUrl)
    }
}


with command options (YourName.kt)

package me.monmcgt.code.commands.impl

import me.monmcgt.code.commands.CommandAbstract
import me.monmcgt.code.commands.CommandInfo
import me.monmcgt.code.commands.RegisterCommand
import net.dv8tion.jda.api.interactions.commands.OptionType
import net.dv8tion.jda.api.interactions.commands.build.OptionData

@RegisterCommand
@CommandInfo(name = "yourname", description = "Returns your name")
class YourName : CommandAbstract() {
    override val optionDataArray: Array<OptionData>
        get() = arrayOf(OptionData(OptionType.STRING, "name", "Your name", true))

    override fun onSlashCommandInteraction() {
        event.getOption("name")?.let {
            sendEmphemralMessage("Your name is ${it.asString}")
        }
    }
}

Library

Inspiration

Releases

No releases published

Packages

No packages published

Languages