Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/discorb-lib/discorb

A Discord API wrapper written in Ruby.
https://github.com/discorb-lib/discorb

discord ruby

Last synced: about 2 months ago
JSON representation

A Discord API wrapper written in Ruby.

Awesome Lists containing this project

README

        

discorb


Document
Gem
Gem
Discord
GitHub
Code Climate maintainability

----

discorb is a Discord API wrapper for Ruby, Using [socketry/async](https://github.com/socketry/async).

## Installation

Add this line to your application's Gemfile:

```ruby
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](/examples) directory.

### Simple Slash Command

```ruby
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

```ruby
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](https://opensource.org/licenses/MIT).