Giter Site home page Giter Site logo

boy0000 / diskord Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jessecorbett/diskord

0.0 0.0 0.0 2.12 MB

[Mirror of GitLab] A Kotlin client for Discord with a light wrapper on the REST APIs and a simple to use DSL for basic bots.

Home Page: https://gitlab.com/jesselcorbett/Diskord

License: Other

Kotlin 100.00%

diskord's Introduction

Diskord - A Kotlin Discord SDK

Maven Central Discord

A multiplatform Kotlin client for Discord bots with a simple and concise DSL supporting JVM and NodeJS

Built as a lean client using coroutines that gets the intricacies of rate limits, async, and data models out of your way in a clean and easy to use SDK

Documentation available here

Using Diskord? Drop by our discord server

How do I import this?

It is strongly recommended to use Gradle version 7 or higher

// Kotlin build.gradle.kts
repositories {
    mavenCentral()
}

dependencies {
    implementation("com.jessecorbett:diskord-bot:5.1.1")
}

Note: The diskord-bot artifact bundles org.slf4j:slf4j-simple to provide basic logging to STDOUT with no configuration. This can be excluded in favor of your own slf4j logger using gradle exclusion:

// Kotlin build.gradle.kts
configurations {
  implementation {
    exclude("org.slf4j", "slf4j-simple")
  }
}

The library is packaged into two artifacts.

diskord-core is the low level implementation of the Discord API. Read more

diskord-bot provides an easier to use API for common bot functions. Read more

How do I use this?

Dokka documentation

For an example project you can easily clone to get started, look at the diskord-starter repo.

There are also a collection of examples in the diskord-examples repo.

Simple Example

import com.jessecorbett.diskord.bot.*
import com.jessecorbett.diskord.util.*

suspend fun main() {
    bot(TOKEN) {
        // Generic hook set for all events
        events {
            onGuildMemberAdd {
                channel(WELCOME_CHANNEL_ID).sendMessage("Welcome to the server, ${it.user?.username}!")
            }
        }
      
        // Modern interactions API for slash commands, user commands, etc
        interactions {
            slashCommand("echo", "Makes the bot say something") {
                val message by stringParameter("message", "The message", optional = true)
                callback {
                    respond {
                        content = if (message != null) {
                            message
                        } else {
                            "The message was null, because it is optional"
                        }
                    }
                }
            }

            commandGroup("emoji", "Send an emoji to the server", guildId = "424046347428167688") {
                subgroup("smile", "Smile emoji") {
                    slashCommand("slight", "A slight smile emoji") {
                        callback {
                            respond {
                                content = "๐Ÿ™‚"
                            }
                        }
                    }
                }

                slashCommand("shh", "The shh emoji") {
                    val secret by stringParameter("secret", "Send the emoji secretly")
                    callback {
                        respond {
                            content = "๐Ÿคซ"
                            if (secret) {
                                ephemeral
                            }
                        }
                    }
                }
            }
        }
      
        // The old-fashioned way, it uses messages, such as .ping, for commands
        classicCommands("!") {
            command("ping") {
                it.respond("pong")
            }
        }
    }
}

FAQ

  • Does this support voice chat?
    • No, voice chat is not supported at this time. If you need it I recommend checking out another SDK
  • Can I contact you to ask a question/contribute to the project/report a bug?
  • What if I'm hip and cool, and I want to use a newer more unstable exciting version?

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.