discorb
Document Gem Gem Discord GitHub Code Climate maintainability

discorb is a Discord API wrapper for Ruby, Using socketry/async.

Installation

Add this line to your application's Gemfile:

gem 'discorb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install discorb

Usage

Note You must run discorb setup before using slash commands.

More examples are available in /examples directory.

Simple Slash Command

require "discorb"

client = Discorb::Client.new

client.once :standby do
  puts "Logged in as #{client.user}"
end

client.slash("ping", "Ping!") do |interaction|
  interaction.post("Pong!", ephemeral: true)
end

client.run(ENV["DISCORD_BOT_TOKEN"])

Legacy Message Command

require "discorb"

intents = Discorb::Intents.new
intents.message_content = true

client = Discorb::Client.new(intents: intents)

client.once :standby do
  puts "Logged in as #{client.user}"
end

client.on :message do |message|
  next if message.author.bot?
  next unless message.content == "ping"

  message.channel.post("Pong!")
end

client.run(ENV["DISCORD_BOT_TOKEN"])

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/discorb-lib/discorb.

License

The gem is available as open source under the terms of the MIT License.