This adds a voice support to discorb.
Add this line to your application's Gemfile:
gem 'discorb-voice'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install discorb-voice
Install discorb-voice_dlls gem. It will install libsodium for you.
bundle add discorb-voice_dlls
Get libsodium from here.
I've checked libsodium-1.0.17-stable-mingw.tar.gz
works.
Then, if you are using x64 ruby (Check with ruby -e 'puts RUBY_PLATFORM'
)...
- extract
libsodium-win64
- copy
libsodium-23.dll
inbin
toC:/Windows/System32/sodium.dll
If you are using x86 ruby...
- extract
libsodium-win32
- copy
libsodium-23.dll
inbin
toC:/Windows/SysWOW64/sodium.dll
.
$ sudo apt-get install libsodium-dev
Get libsodium with your package manager.
$ brew install libsodium
Get ffmpeg from here.
And put the ffmpeg.exe
on your PATH.
Or, you can use Chocolatey to install ffmpeg:
$ choco install ffmpeg
$ sudo apt-get install ffmpeg
Use your package manager to install ffmpeg.
$ brew install ffmpeg
require "discorb"
require "discorb-voice"
client.once :standby do
puts "Logged in as #{client.user}"
end
client.slash "connect", "connect to a voice channel" do |interaction|
channel = interaction.target.voice_state.channel
interaction.post "Connecting to #{channel.name}"
channel.connect.wait
interaction.post "Connected to #{channel.name}"
end
client.slash "play", "Plays audio" do |interaction|
interaction.guild.voice_client.play(Discorb::Voice::FFmpegAudio.new("./very-nice-song.mp3"))
interaction.post "Playing Your very nice song!"
end
client.slash "stop", "Stops the current audio" do |interaction|
interaction.guild.voice_client.stop
interaction.post "Stopped"
end
client.run(ENV["DISCORD_BOT_TOKEN"])
After checking out the repo, run bin/setup
to install dependencies. 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 the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/discorb-lib/discorb-voice.
The gem is available as open source under the terms of the MIT License.
The implementation of the voice client is based on discord.py library.
Copyright (c) 2015-present Rapptz
Released under the MIT license
https://github.com/Rapptz/discord.py/blob/master/LICENSE