Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Abdera7mane/cordot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ℹ️ Note: If you are looking to integrate your game with the Discord client, check out Discord RPC.

Cordot

icon

Discord API wrapper for Godot Engine written in GDScript language.

Godot version Discord API version License

Features

  • Object oriented
  • Statically typed
  • Supports gateway resumes and auto reconnects when possible

Example

A minimal bot written using this library

extends Node

var token: String = "bot_token"
var client: DiscordClient = DiscordClient.new(token)

func _ready() -> void:
    add_child(client)
    
    client.connect("client_ready", self, "_on_bot_ready")
    client.connect("message_sent", self, "_on_message")

    client.login()

func _on_bot_ready(user: User) -> void:
    print("Bot is ready !")
    print("logged as: ", user.get_tag())

    var presence := PresenceUpdate.new()
    presence.set_status(Presence.Status.DND)\
            .add_activity(Presence.playing("Godot Engine"))

    client.update_presence(presence)

func _on_message(message: Message) -> void:
    if message.author.is_bot:
        return

    if message.content.to_lower().begins_with("hello"):
        message.channel.create_message("Greetings !").submit()

Installation

git clone --recursive https://github.com/Abdera7mane/cordot
cd cordot
git submodule update --init --recursive

Open the folder as a Godot project or copy the addons directory to an existing project.

Documentation

The documentation is hosted on ReadTheDocs.
Contributions to cordot-docs are welcomed.

Usage

Even though this may seem useless for a Godot game, I find this project being useful in some scenarios:

  • Learning resource
  • Running a discord bot in a Godot game server

It is always up to you and your creativity on how you will use this project as long as you don't abuse the Discord API.