lib_discord
Straightforward Ruby-bindings for Discord's Web API
project -- sources -- mailing lists -- bug tracker
Installation
lib_discord
requires an installed Ruby runtime
>= 3.3
.
Install the gem and add it to your application's Gemfile:
bundle add lib_discord
If bundler is not being used to manage dependencies, install the gem with:
gem install lib_discord
Usage
Use the Client for communicating with Discord's web endpoints
require "lib_discord"
client = LibDiscord.client("Bot my.amazing.bot.token") # => LibDiscord::Client
resp = client.("<channel_id>", {content: "Hi, Mom!"}) # => LibDiscord::Response
resp.success? # => true
Compare permissions:
p = LibDiscord. # => Hash
= p[:SEND_MESSAGES] + p[:ADD_REACTIONS] # => 2112
# Check for permission flags that are set.
& p[:SEND_MESSAGES] == p[:SEND_MESSAGES] # => true
# Check for permission flags that are not set.
& p[:KICK_MEMBERS] == p[:KICK_MEMBERS] # => false
Use maps for Discord's encoded values:
aco_types = LibDiscord.maps[:ApplicationCommand][:OptionTypes] # => Hash
aco_types[:CHANNEL] # => 7
Format Discord specific objects to render in messages:
fmt = LibDiscord.formatter
fmt.user(12345678) # => "<@12345678>"
See documentation for more details.
Getting help
Please use the mailing lists if you have questions or need assistance.
Contributing
Bug reports and patch submissions are welcome on SourceHut via the bug tracker and mailing lists, respectively. This project is intended to be a safe and welcoming space for collaboration. All participants are expected to adhere to the code of conduct.
See CONTRIBUTING.md for more details.
Licenses
See files in the LICENSES/ directory.