Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interaction permissions to MemberData and Member #884

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -4241,21 +4241,22 @@ public final class dev/kord/core/cache/data/InviteWithMetadataData$Companion {

public final class dev/kord/core/cache/data/MemberData {
public static final field Companion Ldev/kord/core/cache/data/MemberData$Companion;
public synthetic fun <init> (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ILdev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/kord/common/entity/Snowflake;
public final fun component10 ()Ldev/kord/common/entity/optional/Optional;
public final fun component11 ()Ldev/kord/common/entity/optional/Optional;
public final fun component2 ()Ldev/kord/common/entity/Snowflake;
public final fun component3 ()Ldev/kord/common/entity/optional/Optional;
public final fun component4 ()Ljava/util/List;
public final fun component5 ()Lkotlinx/datetime/Instant;
public final fun component6 ()Ldev/kord/common/entity/optional/Optional;
public final fun component7 ()Ldev/kord/common/entity/GuildMemberFlags;
public final fun component8 ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun component9 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/MemberData;
public static synthetic fun copy$default (Ldev/kord/core/cache/data/MemberData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/MemberData;
public final fun component8 ()Ldev/kord/common/entity/optional/Optional;
public final fun component9 ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/core/cache/data/MemberData;
public static synthetic fun copy$default (Ldev/kord/core/cache/data/MemberData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/GuildMemberFlags;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/core/cache/data/MemberData;
public fun equals (Ljava/lang/Object;)Z
public final fun getAvatar ()Ldev/kord/common/entity/optional/Optional;
public final fun getCommunicationDisabledUntil ()Ldev/kord/common/entity/optional/Optional;
Expand All @@ -4264,6 +4265,7 @@ public final class dev/kord/core/cache/data/MemberData {
public final fun getJoinedAt ()Lkotlinx/datetime/Instant;
public final fun getNick ()Ldev/kord/common/entity/optional/Optional;
public final fun getPending ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun getPermissions ()Ldev/kord/common/entity/optional/Optional;
public final fun getPremiumSince ()Ldev/kord/common/entity/optional/Optional;
public final fun getRoles ()Ljava/util/List;
public final fun getUserId ()Ldev/kord/common/entity/Snowflake;
Expand Down Expand Up @@ -6655,6 +6657,7 @@ public final class dev/kord/core/entity/Member : dev/kord/core/entity/User, dev/
public final fun getMemberAvatarHash ()Ljava/lang/String;
public final fun getMemberData ()Ldev/kord/core/cache/data/MemberData;
public final fun getNickname ()Ljava/lang/String;
public final fun getPermissions ()Ldev/kord/common/entity/Permissions;
public final fun getPermissions (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getPremiumSince ()Lkotlinx/datetime/Instant;
public fun getPresence (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
2 changes: 2 additions & 0 deletions core/src/commonMain/kotlin/cache/data/MemberData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public data class MemberData(
val joinedAt: Instant,
val premiumSince: Optional<Instant?> = Optional.Missing(),
val flags: GuildMemberFlags,
val permissions: Optional<Permissions> = Optional.Missing(),
val pending: OptionalBoolean = OptionalBoolean.Missing,
val avatar: Optional<String?> = Optional.Missing(),
val communicationDisabledUntil: Optional<Instant?> = Optional.Missing()
Expand Down Expand Up @@ -53,6 +54,7 @@ public data class MemberData(
joinedAt = joinedAt,
premiumSince = premiumSince,
flags = flags,
permissions = Optional.Value(permissions),
pending = pending,
avatar = avatar,
communicationDisabledUntil = communicationDisabledUntil,
Expand Down
8 changes: 8 additions & 0 deletions core/src/commonMain/kotlin/entity/Member.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dev.kord.core.behavior.RoleBehavior
import dev.kord.core.behavior.UserBehavior
import dev.kord.core.cache.data.MemberData
import dev.kord.core.cache.data.UserData
import dev.kord.core.entity.interaction.GuildInteraction
import dev.kord.core.supplier.EntitySupplier
import dev.kord.core.supplier.EntitySupplyStrategy
import kotlinx.coroutines.flow.*
Expand Down Expand Up @@ -93,6 +94,13 @@ public class Member(
/** The [GuildMemberFlags] of this member. */
public val flags: GuildMemberFlags get() = memberData.flags

/**
* The total [Permissions] of this member in the channel an interaction was sent from.
*
* This is only non-null when obtained from a [GuildInteraction].
*/
public val permissions: Permissions? get() = memberData.permissions.value

/**
* Whether the user has not yet passed the guild's Membership Screening requirements.
*/
Expand Down