Skip to content

Commit

Permalink
bug fix (hopefully works)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumap committed Jul 6, 2021
1 parent 4ad1c00 commit 23206f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ export class Client extends EventEmitter {
: guildOrId;
const member =
typeof memberOrId === "bigint"
? await this.cache.get("members", memberOrId)
? guild ? await this.helpers.members.getMember(guild.id,memberOrId) : null
: memberOrId;

if (!guild || !member) return 8n;

let permissions = 0n;
console.log(member.guilds.get(guild.id)?.roles)
// Calculate the role permissions bits, @everyone role is not in memberRoleIds so we need to pass guildId manualy
permissions |=
[...(member.guilds.get(guild.id)?.roles || []), guild.id]
Expand All @@ -565,7 +565,6 @@ export class Client extends EventEmitter {
bits! |= BigInt(perms?.bits!);
return bits;
}, 0n) || 0n;

// If the memberId is equal to the guild ownerId he automatically has every permission so we add ADMINISTRATOR permission
if (guild.ownerId === member.id) permissions |= 8n;
// Return the members permission bits as a string
Expand Down Expand Up @@ -751,12 +750,12 @@ export class Client extends EventEmitter {
}

/** Throws an error if the bot does not have all permissions */
requireBotGuildPermissions(
async requireBotGuildPermissions(
guild: bigint | UniversityGuild,
permissions: PermissionStrings[]
) {
// Since Bot is a normal member we can use the throwOnMissingGuildPermission() function
return this.requireGuildPermissions(guild, this.botId, permissions);
return await this.requireGuildPermissions(guild, this.botId, permissions);
}

/** Throws an error if this member has not all of the given permissions */
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Helpers/Members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ export class MemberHelpers {
const guild = await this.client.cache.get("guilds", guildId);
if (!guild && !options?.force) return;

const member = await this.client.cache.get("members",id)
if (member && member.guilds.get(guildId)) return member
const data = (await this.client.rest.get(
endpoints.GUILD_MEMBER(guildId, id)
)) as GuildMemberWithUser;
Expand Down

0 comments on commit 23206f3

Please sign in to comment.