Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/discorb-lib/discorb
- Owner: discorb-lib
- License: mit
- Created: 2021-06-26T02:16:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T21:22:14.000Z (4 months ago)
- Last Synced: 2024-09-10T02:08:51.860Z (4 months ago)
- Topics: discord, ruby
- Language: Ruby
- Homepage: https://discorb-lib.github.io
- Size: 6.07 MB
- Stars: 36
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-discord - discorb
README
----
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}"
endclient.slash("ping", "Ping!") do |interaction|
interaction.post("Pong!", ephemeral: true)
endclient.run(ENV["DISCORD_BOT_TOKEN"])
```### Legacy Message Command
```ruby
require "discorb"intents = Discorb::Intents.new
intents.message_content = trueclient = Discorb::Client.new(intents: intents)
client.once :standby do
puts "Logged in as #{client.user}"
endclient.on :message do |message|
next if message.author.bot?
next unless message.content == "ping"message.channel.post("Pong!")
endclient.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).