Created
February 19, 2021 08:34
-
-
Save tomaszwro/c6574aa95c0c4009adcba92a8da2cec1 to your computer and use it in GitHub Desktop.
Revisions
-
tomaszwro created this gist
Feb 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ require "discordrb" require "httparty" def notify_slack(message) HTTParty.post( "https://hooks.slack.com/services/xxx/xxxx/xxxxx", body: JSON.dump({ text: message }), headers: { "Content-Type" => "application/json" } ) end bot = Discordrb::Bot.new(token: "xxxx.xxx.xxxx") bot.voice_state_update do |event| case when event.channel.nil? notify_slack "✂️ #{event.user.name} disconnected" when event.old_channel.nil? notify_slack "👋 #{event.user.name} connected to #{event.channel.name}" when event.channel.name != event.old_channel.name notify_slack "🔀 #{event.user.name} switched to #{event.channel.name}" end end at_exit { bot.stop } bot.run