local consts = require'discord.consts' local websocket = require'http.websocket' local json = require 'dkjson' local Queue = require 'queue' local exec_webhook = require'discord.the' local cqueues = require 'cqueues' local pylon = require 'pylon' local Discord = pylon.subclass "discord" function Discord.init(self) self:check_config "token" end local function identify_payload(token) local I = consts.intents return json.encode{ op = consts.opcodes.identify, d = { properties = { os = "wilson", browser = "wilson", device = "wilson", }, intents = I.guilds + I.guild_messages + I.message_content, token = token, } } end function Discord._connect(self) local uri = "wss://gateway.discord.gg/?v=10&encoding=json" self.ws = websocket.new_from_uri(uri) assert(self.ws:connect()) self.ws:send(identify_payload(self.token), 'text') -- for a,b in self.ws:each() do -- print('its',a,b) -- end end function Discord.recving(self) for event in self.ws:each() do print(event) end end function Discord.sending(self) for dest_channel, message in self.inbox:iter() do print('DDD',message.sender,message.body) exec_webhook(self.temp_wh, { username = message.sender, content = message.body, }) end end return Discord