Skip to content

snapcase/discordrb

This branch is 1898 commits behind discordrb/discordrb:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b434656 · Apr 15, 2016
Dec 4, 2015
Apr 15, 2016
Apr 11, 2016
Apr 11, 2016
Nov 9, 2015
Mar 22, 2016
Nov 28, 2015
Apr 10, 2016
Feb 10, 2016
Jan 24, 2016
Apr 10, 2016
Aug 18, 2015
Aug 18, 2015
Apr 8, 2016
Jan 6, 2016
Apr 5, 2016

Repository files navigation

Gem Gem Build Status Inline docs Join Discord

discordrb

An implementation of the Discord API using Ruby.

Quick links to sections

See also: Documentation, Tutorials

Dependencies

  • Ruby 2.1+
  • An installed build system for native extensions (on Windows, try the DevKit; installation instructions here)

Voice dependencies

This section only applies to you if you want to use voice functionality.

  • libsodium
  • A compiled libopus distribution for your system, anywhere the script can find it (on Windows, make sure it's named opus.dll)
  • FFmpeg installed and in your PATH

Installation

Linux

On Linux, it should be as simple as running:

gem install discordrb

Windows

On Windows, to install discordrb, run this in a shell:

gem install discordrb

Run the ping example to verify that the installation works (make sure to replace the username and password in there with your own or your bots'!):

ruby ping.rb

Troubleshooting

If you get an error like this when installing the gem:

ERROR:  Error installing discordrb:
        The 'websocket-driver' native gem requires installed build tools.

You're missing the development kit required to build native extensions. Download the development kit here (scroll down to "Development Kit", then choose the one for Ruby 2.0 and your system architecture) and extract it somewhere. Open a command prompt in that folder and run:

ruby dk.rb init
ruby dk.rb install

Then reinstall discordrb:

gem uninstall discordrb
gem install discordrb

If you're having trouble getting voice playback to work:

Look here: https://github.com/meew0/discordrb/wiki/Voice-sending#troubleshooting

Usage

You can make a simple bot like this:

require 'discordrb'

bot = Discordrb::Bot.new token: '<token here>', application_id: 168123456789123456

bot.message(with_text: 'Ping!') do |event|
  event.respond 'Pong!'
end

bot.run

This bot responds to every "Ping!" with a "Pong!".

Support

You can find me (@meew0, ID 66237334693085184) on the unofficial Discord API server - if you have a question, just ask there, I or somebody else will probably answer you: https://discord.gg/0SBTUU1wZTWfFQL2

Development

This section is for developing discordrb itself! If you just want to make a bot, see the Installation section.

After checking out the repo, run bin/setup to install dependencies. You can then run tests via bundle exec rspec spec. Make sure to run rubocop also: bundle exec rubocop. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/meew0/discordrb.

License

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

Packages

No packages published

Languages

  • Ruby 100.0%