SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
688 stars 144 forks source link

Fix error in Member:getPermissions() #397

Closed RiskoZoSlovenska closed 10 months ago

RiskoZoSlovenska commented 1 year ago

In Member.lua on lines 220-221, we index a number, leading to an error whenever Member:getPermissions() is called:

local allow, deny = 0, 0
for role in self.roles:iter() do
    if role.id ~= guild.id then -- just in case
        local overwrite = overwrites:get(role.id)
        if overwrite then
            deny = deny:union(overwrite:getDeniedPermissions())
            allow = allow:union(overwrite:getAllowedPermissions())
        end
    end
end

Looks like this was caused by https://github.com/SinisterRectus/Discordia/commit/6493e89d787199b592c6b1fbb8f562487030053f, when numbers were swapped out for objects. This PR fixes the error by replacing the values of allow and deny with blank Permissions objects.

SinisterRectus commented 10 months ago

Looks good to me, thank you!