Skip to content

Xh4H/Discord.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord.jl

Documentation Build Status Information
Docs Build Status Discord License

Discord.jl is the solution for creating Discord bots with the Julia programming language.

  • Strong, expressive type system: No fast-and-loose JSON objects here.
  • Non-blocking: API calls return immediately and can be awaited when necessary.
  • Simple: Multiple dispatch allows for a small, elegant core API.
  • Fast: Julia is fast like C but still easy like Python.
  • Robust: Resistant to bad event handlers and/or requests. Errors are introspectible for debugging.
  • Lightweight: Cache what is important but shed dead weight with TTL.
  • Gateway independent: Ability to interact with Discord's API without establishing a gateway connection.
  • Distributed: Process-based sharding requires next to no intervention and you can even run shards on separate machines.

Installation

First install Julia. Make sure you are running the latest version.

Discord.jl is not yet released. Add it from the Git repository with the following command:

# Enter ']' from the REPL to enter Pkg mode.
pkg> add https://github.com/Xh4H/Discord.jl

The above command will also update all of your dependencies, and store the configurations in ~/.julia.

Example

# Import Discord.jl.
using Discord
# Create a client.
c = Client("token"; presence=(game=(name="with Discord.jl", type=AT_GAME),))

# Create a handler for the MessageCreate event.
function handler(c::Client, e::MessageCreate)
    # Display the message contents.
    println("Received message: $(e.message.content)")
    # Add a reaction to the message.
    create(c, Reaction, e.message, '👍')
end

# Add the handler.
add_handler!(c, MessageCreate, handler)
# Log in to the Discord gateway.
open(c)
# Wait for the client to disconnect.
wait(c)

For further examples, guides and reference please refer to the documentation linked above.

Contributing

Pull requests are welcome! In most cases, it will be helpful to discuss the change you would like to make on Discord before diving in too deep.

Credits

Big thanks to christopher-dG for developing this project with me, and also TheOnlyArtz for initially starting up this repository with me.