summaryrefslogtreecommitdiff
path: root/discord/pylon.lua
diff options
context:
space:
mode:
Diffstat (limited to 'discord/pylon.lua')
-rw-r--r--discord/pylon.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/discord/pylon.lua b/discord/pylon.lua
index ebf185d..c2afc3a 100644
--- a/discord/pylon.lua
+++ b/discord/pylon.lua
@@ -15,7 +15,7 @@ local API_BASE = "https://discord.com/api/v10/"
local Discord = class.extend(BasePylon)
function Discord.init(self)
self:_check_fields "token"
- self.channel_to_webhook = {}
+ self.channels = {}
end
local function identify_payload(token)
@@ -76,14 +76,14 @@ function Discord.add_channel(self, channel)
for _,wh in pairs(webhooks) do
if wh.application_id == self.bot_id then
self.log("Found existing webhook for channel",channel.id)
- self.channel_to_webhook[channel.id] = wh
+ self.channels[channel.id] = {wh=wh}
return
end
end
self.log("Making webhook for channel",channel.id)
local wh = self:_req("channels/"..channel.id.."/webhooks", {
name=self.name:gsub("discord",""):gsub("clyde","").." wilson hook" })
- self.channel_to_webhook[channel.id] = wh
+ self.channels[channel.id] = {wh=wh}
end
function Discord._heartbeating(self, interval_ms)
@@ -121,8 +121,8 @@ function Discord.handle_dispatch(self, event)
if event.t == 'MESSAGE_CREATE' then
self.log:proto('<',d.channel_id,d.author.username,d.content)
if
- self.channel_to_webhook[d.channel_id]
- and d.author.id ~= self.channel_to_webhook[d.channel_id].id
+ self.channels[d.channel_id]
+ and d.author.id ~= self.channels[d.channel_id].wh.id
and d.author.id ~= self.bot_id
then
self.wilson:deliver(Message {
@@ -138,7 +138,7 @@ end
function Discord.sending(self)
for dest_channel, message in self.inbox:iter() do
self.log:proto('>',dest_channel,message.author,message.body)
- local wh = self.channel_to_webhook[dest_channel.id]
+ local wh = self.channels[dest_channel.id].wh
self:_req('webhooks/'..wh.id..'/'..wh.token, {
username = message.author:name_with_shortname(),
content = message.body,