allow multiple components to display shared user menu

This commit is contained in:
ouwou
2020-11-08 00:44:26 -05:00
parent 0c442a423e
commit f124626a6d
12 changed files with 143 additions and 105 deletions

View File

@@ -330,13 +330,11 @@ Permission DiscordClient::ComputeOverwrites(Permission base, Snowflake member_id
return perms;
}
bool DiscordClient::CanManageMember(Snowflake channel_id, Snowflake actor, Snowflake target) const {
const auto *channel = GetChannel(channel_id);
if (channel == nullptr) return false;
const auto *guild = GetGuild(channel->GuildID);
bool DiscordClient::CanManageMember(Snowflake guild_id, Snowflake actor, Snowflake target) const {
const auto *guild = GetGuild(guild_id);
if (guild != nullptr && guild->OwnerID == target) return false;
const auto actor_highest_id = GetMemberHighestRole(channel->GuildID, actor);
const auto target_highest_id = GetMemberHighestRole(channel->GuildID, target);
const auto actor_highest_id = GetMemberHighestRole(guild_id, actor);
const auto target_highest_id = GetMemberHighestRole(guild_id, target);
const auto *actor_highest = GetRole(actor_highest_id);
const auto *target_highest = GetRole(target_highest_id);
if (actor_highest == nullptr) return false;

View File

@@ -93,7 +93,7 @@ public:
bool HasChannelPermission(Snowflake user_id, Snowflake channel_id, Permission perm) const;
Permission ComputePermissions(Snowflake member_id, Snowflake guild_id) const;
Permission ComputeOverwrites(Permission base, Snowflake member_id, Snowflake channel_id) const;
bool CanManageMember(Snowflake channel_id, Snowflake actor, Snowflake target) const; // kick, ban, edit nickname (cant think of a better name)
bool CanManageMember(Snowflake guild_id, Snowflake actor, Snowflake target) const; // kick, ban, edit nickname (cant think of a better name)
void SendChatMessage(std::string content, Snowflake channel);
void DeleteMessage(Snowflake channel_id, Snowflake id);