Sha256: c6f5b623029b36a3758a2a7bc9cb92d55f4b93d1bcb746557988dfed9eb0cda0
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
require "discorb" require "discorb/voice" require "open3" client = Discorb::Client.new 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 YouTube audio", { "url" => { type: :string, description: "The URL of the YouTube video to play", required: true, }, } do |interaction, url| interaction.post "Querying #{url}..." stdout, _status = Open3.capture2("youtube-dl", "-j", url) data = JSON.parse(stdout, symbolize_names: true) url = data[:formats][0][:url] interaction.guild.voice_client.play(Discorb::Voice::FFmpegAudio.new(url)) interaction.post "Playing `#{data[:title]}`" 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"])
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
discorb-voice-0.1.2 | examples/music_bot.rb |
discorb-voice-0.1.1 | examples/music_bot.rb |
discorb-voice-0.1.0 | examples/music_bot.rb |