discorb is a Discord API wrapper for Ruby, Using socketry/async.
Add this line to your application's Gemfile:
gem 'discorb'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install discorb
Note You must run
discorb setup
before using slash commands.
More examples are available in /examples directory.
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"])
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"])
Bug reports and pull requests are welcome on GitHub at https://github.com/discorb-lib/discorb.
The gem is available as open source under the terms of the MIT License.