discrod

Version, currently master branch1 version
  • master branchlatestMay 8, 2020

github.com/voximity/discrod

Experimental Discord library for Crystal

0 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  discrod:
    github: voximity/discrod
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.34.0
License
MIT
Author
voximity

Dependencies

Runtime Dependencies

  • emoji*github: veelenga/emoji.cr, branch: master

README

discrod

discrod is an experimental Discord library for Crystal. I am writing this to serve as a replacement for one of my bot projects' current implementation in C#.

If you are looking for a production-ready Discord library, check out discordcr. This library is not ready for full use.

Installation

Add this to your application's shard.yml:

dependencies:
    discrod:
        github: voximity/discrod

Usage

require "discrod"

client = Discrod::Client.new token: "my-token", token_type: Discrod::TokenType::Bot

client.on_message_create do |message|
    if message.content == "ping"
        builder = Discrod::EmbedBuilder.new do |e|
            e.with_title "Pong!"
            e.with_description "discrod speaking!"
            e.with_current_time
            e.with_author(message.author)
        end

        message.react Discrod::Emoji.new ":confetti_ball:"
        message.channel.create_message embed: builder.build
    end
end

client.connect

All endpoints are available in Client as low-level API calls with very little abstraction between. For higher-level API calls, each resource has their appropriate methods to help mitigate Client usage. For example, Message#delete is synonymous with Client#delete_message(channel_id, message_id).

Caches

By default, resource caching is enabled. You can assign a cache to periodically wipe:

client.guild_cache!.clear_periodic 1.hours

Contributing

  1. Fork it (https://github.com/voximity/discrod/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request