Skip to content

Commit

Permalink
Preparation for Discord API version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
SinisterRectus committed Jan 16, 2023
1 parent dc84182 commit eb05579
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
9 changes: 6 additions & 3 deletions libs/client/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ local insert, concat = table.insert, table.concat
local sleep = timer.sleep
local running = coroutine.running

local BASE_URL = "https://discord.com/api/v7"

local VERSION = 7
local BASE_URL = "https://discord.com/api/" .. 'v' .. VERSION
local JSON = 'application/json'
local PRECISION = 'millisecond'
local MULTIPART = 'multipart/form-data;boundary='
Expand Down Expand Up @@ -144,10 +144,13 @@ function API:request(method, endpoint, payload, query, files)

local req = {
{'User-Agent', USER_AGENT},
{'X-RateLimit-Precision', PRECISION},
{'Authorization', self._token},
}

if VERSION < 8 then
insert(req, {'X-RateLimit-Precision', PRECISION})
end

if payloadRequired[method] then
payload = payload and encode(payload) or '{}'
if files and next(files) then
Expand Down
64 changes: 57 additions & 7 deletions libs/client/EventHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,6 @@ function EventHandler.PRESENCE_UPDATE(d, client) -- may have incomplete data
else
if d.status == 'offline' then -- uncache offline members
member = guild._members:_delete(d.user.id)
else
if d.user.username then -- member was offline
member = guild._members:_insert(d)
elseif user then -- member was invisible, user is still cached
member = guild._members:_insert(d)
member._user = user
end
end
end
if member then
Expand Down Expand Up @@ -537,4 +530,61 @@ function EventHandler.WEBHOOKS_UPDATE(d, client) -- webhook object is not provid
return client:emit('webhooksUpdate', channel)
end

function EventHandler.AUTO_MODERATION_RULE_CREATE(d, client)
end

function EventHandler.AUTO_MODERATION_RULE_UPDATE(d, client)
end

function EventHandler.AUTO_MODERATION_RULE_DELETE(d, client)
end

function EventHandler.AUTO_MODERATION_ACTION_EXECUTION(d, client)
end

function EventHandler.THREAD_CREATE(d, client)
end

function EventHandler.THREAD_UPDATE(d, client)
end

function EventHandler.THREAD_DELETE(d, client)
end

function EventHandler.THREAD_LIST_SYNC(d, client)
end

function EventHandler.THREAD_MEMBER_UPDATE(d, client)
end

function EventHandler.THREAD_MEMBERS_UPDATE(d, client)
end

function EventHandler.GUILD_STICKERS_UPDATE(d, client)
end

function EventHandler.GUILD_SCHEDULED_EVENT_CREATE(d, client)
end

function EventHandler.GUILD_SCHEDULED_EVENT_UPDATE(d, client)
end

function EventHandler.GUILD_SCHEDULED_EVENT_DELETE(d, client)
end

function EventHandler.GUILD_SCHEDULED_EVENT_USER_ADD(d, client)
end

function EventHandler.GUILD_SCHEDULED_EVENT_USER_REMOVE(d, client)
end

function EventHandler.STAGE_INSTANCE_CREATE(d, client)
end

function EventHandler.STAGE_INSTANCE_UPDATE(d, client)
end

function EventHandler.STAGE_INSTANCE_DELETE(d, client)
end

return EventHandler

0 comments on commit eb05579

Please sign in to comment.