vrobot4/source/sv_discord.rb

30 lines
606 B
Ruby

require 'discordrb'
class Sv_Discord < Vrobot4::Server::Server
Vrobot4::Server.add_server_type self, "Discord"
def initialize info
super()
@bot = Discordrb::Bot.new \
token: info["apikey"],
client_id: info["client"]
@bot.message do |evt|
m = Vrobot4::Server::Message.new(evt.message.content)
if m.msg.start_with? '.'
argv = m.msg.split
cnam = argv.shift[1..-1]
onCommand m, cnam, argv
else
onMessage m
end
end
end
def connect
@bot.run
end
end
## EOF