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

Allow modifying GuildMemberFlags #865

Merged
merged 1 commit into from
Sep 2, 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
50 changes: 28 additions & 22 deletions common/api/common.api

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions common/src/commonMain/kotlin/entity/Member.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import kotlinx.serialization.Serializable
@Serializable
public data class DiscordGuildMember(
val user: Optional<DiscordUser> = Optional.Missing(),
/*
Don't trust the docs:
2020-11-05 nick is only documented as nullable but can be missing through Gateway
*/
val nick: Optional<String?> = Optional.Missing(),
val roles: List<Snowflake>,
@SerialName("joined_at")
Expand All @@ -46,17 +42,14 @@ public data class DiscordGuildMember(
@Serializable
public data class DiscordInteractionGuildMember(
val user: Optional<DiscordUser> = Optional.Missing(),
/*
Don't trust the docs:
2020-11-05 nick is only documented as nullable but can be missing through Gateway
*/
val nick: Optional<String?> = Optional.Missing(),
val roles: List<Snowflake>,
@SerialName("joined_at")
val joinedAt: Instant,
@SerialName("premium_since")
val premiumSince: Optional<Instant?> = Optional.Missing(),
val permissions: Permissions,
val flags: GuildMemberFlags,
val pending: OptionalBoolean = OptionalBoolean.Missing,
val avatar: Optional<String?> = Optional.Missing(),
@SerialName("communication_disabled_until")
Expand All @@ -67,10 +60,6 @@ public data class DiscordInteractionGuildMember(
@Serializable
public data class DiscordAddedGuildMember(
val user: Optional<DiscordUser> = Optional.Missing(),
/*
Don't trust the docs:
2020-11-05 nick is only documented as nullable but can be missing through Gateway
*/
val nick: Optional<String?> = Optional.Missing(),
val roles: List<Snowflake>,
@SerialName("joined_at")
Expand All @@ -79,6 +68,7 @@ public data class DiscordAddedGuildMember(
val premiumSince: Optional<Instant?> = Optional.Missing(),
val deaf: Boolean,
val mute: Boolean,
val flags: GuildMemberFlags,
@SerialName("guild_id")
val guildId: Snowflake,
val pending: OptionalBoolean = OptionalBoolean.Missing,
Expand All @@ -105,6 +95,7 @@ public data class DiscordUpdatedGuildMember(
val joinedAt: Instant,
@SerialName("premium_since")
val premiumSince: Optional<Instant?> = Optional.Missing(),
val flags: GuildMemberFlags,
val pending: OptionalBoolean = OptionalBoolean.Missing,
val avatar: Optional<String?> = Optional.Missing(),
@SerialName("communication_disabled_until")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"premium_since": null,
"permissions": "2147483647",
"pending": false,
"flags": 3,
"nick": null,
"mute": false,
"joined_at": "2020-04-03T09:35:54.879000+00:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"premium_since": null,
"permissions": "2147483647",
"pending": false,
"flags": 3,
"nick": null,
"mute": false,
"joined_at": "2020-04-03T09:35:54.879000+00:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"joined_at": "2020-11-02T19:25:47.248000+00:00",
"mute": false,
"nick": "Bot Man",
"flags": 3,
"pending": false,
"permissions": "17179869183",
"premium_since": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"premium_since": null,
"permissions": "2147483647",
"flags": 3,
"pending": false,
"nick": null,
"mute": false,
Expand Down
17 changes: 10 additions & 7 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -4181,23 +4181,25 @@ 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/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/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/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/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 final fun component1 ()Ldev/kord/common/entity/Snowflake;
public final fun component10 ()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/optional/OptionalBoolean;
public final fun component8 ()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/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/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 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 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;
public final fun getFlags ()Ldev/kord/common/entity/GuildMemberFlags;
public final fun getGuildId ()Ldev/kord/common/entity/Snowflake;
public final fun getJoinedAt ()Lkotlinx/datetime/Instant;
public final fun getNick ()Ldev/kord/common/entity/optional/Optional;
Expand Down Expand Up @@ -6611,6 +6613,7 @@ public final class dev/kord/core/entity/Member : dev/kord/core/entity/User, dev/
public final fun getCommunicationDisabledUntil ()Lkotlinx/datetime/Instant;
public final fun getDisplayName ()Ljava/lang/String;
public final fun getEffectiveName ()Ljava/lang/String;
public final fun getFlags ()Ldev/kord/common/entity/GuildMemberFlags;
public fun getGuild ()Ldev/kord/core/behavior/GuildBehavior;
public fun getGuild (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun getGuildId ()Ldev/kord/common/entity/Snowflake;
Expand Down
5 changes: 5 additions & 0 deletions core/src/commonMain/kotlin/cache/data/MemberData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public data class MemberData(
val roles: List<Snowflake>,
val joinedAt: Instant,
val premiumSince: Optional<Instant?> = Optional.Missing(),
val flags: GuildMemberFlags,
val pending: OptionalBoolean = OptionalBoolean.Missing,
val avatar: Optional<String?> = Optional.Missing(),
val communicationDisabledUntil: Optional<Instant?> = Optional.Missing()
Expand All @@ -34,6 +35,7 @@ public data class MemberData(
roles = roles,
joinedAt = joinedAt,
premiumSince = premiumSince,
flags = flags,
pending = pending,
avatar = avatar,
communicationDisabledUntil = communicationDisabledUntil,
Expand All @@ -50,6 +52,7 @@ public data class MemberData(
roles = roles,
joinedAt = joinedAt,
premiumSince = premiumSince,
flags = flags,
pending = pending,
avatar = avatar,
communicationDisabledUntil = communicationDisabledUntil,
Expand All @@ -64,6 +67,7 @@ public data class MemberData(
roles = roles,
joinedAt = joinedAt,
premiumSince = premiumSince,
flags = flags,
pending = pending,
avatar = avatar,
communicationDisabledUntil = communicationDisabledUntil,
Expand All @@ -78,6 +82,7 @@ public data class MemberData(
roles = roles,
joinedAt = joinedAt,
premiumSince = premiumSince,
flags = flags,
pending = pending,
avatar = avatar,
communicationDisabledUntil = communicationDisabledUntil,
Expand Down
4 changes: 4 additions & 0 deletions core/src/commonMain/kotlin/entity/Member.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.kord.core.entity

import dev.kord.common.entity.ALL
import dev.kord.common.entity.GuildMemberFlags
import dev.kord.common.entity.Permissions
import dev.kord.common.entity.Snowflake
import dev.kord.common.exception.RequestException
Expand Down Expand Up @@ -97,6 +98,9 @@ public class Member(
get() = if (roleIds.isEmpty()) emptyFlow()
else supplier.getGuildRoles(guildId).filter { it.id in roleIds }

/** The [GuildMemberFlags] of this member. */
public val flags: GuildMemberFlags get() = memberData.flags

/**
* Whether the user has not yet passed the guild's Membership Screening requirements.
*/
Expand Down
2 changes: 2 additions & 0 deletions core/src/commonTest/kotlin/live/LiveGuildTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class LiveGuildTest : AbstractLiveEntityTest<LiveGuild>() {
deaf = false,
mute = false,
joinedAt = Instant.fromEpochMilliseconds(0),
flags = GuildMemberFlags(),
),
0
)
Expand Down Expand Up @@ -380,6 +381,7 @@ class LiveGuildTest : AbstractLiveEntityTest<LiveGuild>() {
avatar = null
),
joinedAt = Instant.fromEpochMilliseconds(0),
flags = GuildMemberFlags(),
),
0
)
Expand Down
2 changes: 2 additions & 0 deletions core/src/commonTest/kotlin/live/LiveMemberTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class LiveMemberTest : AbstractLiveEntityTest<LiveMember>() {
joinedAt = Instant.fromEpochMilliseconds(0),
premiumSince = Optional.Missing(),
avatar = Optional.Missing(),
flags = GuildMemberFlags(),
),
userData = UserData(
id = userId,
Expand Down Expand Up @@ -69,6 +70,7 @@ class LiveMemberTest : AbstractLiveEntityTest<LiveMember>() {
avatar = null
),
joinedAt = Instant.fromEpochMilliseconds(0),
flags = GuildMemberFlags(),
),
0
)
Expand Down
14 changes: 9 additions & 5 deletions rest/api/rest.api
Original file line number Diff line number Diff line change
Expand Up @@ -1833,13 +1833,15 @@ public final class dev/kord/rest/builder/member/MemberModifyBuilder : dev/kord/r
public fun <init> ()V
public final fun getCommunicationDisabledUntil ()Lkotlinx/datetime/Instant;
public final fun getDeafened ()Ljava/lang/Boolean;
public final fun getFlags ()Ldev/kord/common/entity/GuildMemberFlags;
public final fun getMuted ()Ljava/lang/Boolean;
public final fun getNickname ()Ljava/lang/String;
public fun getReason ()Ljava/lang/String;
public final fun getRoles ()Ljava/util/Set;
public final fun getVoiceChannelId ()Ldev/kord/common/entity/Snowflake;
public final fun setCommunicationDisabledUntil (Lkotlinx/datetime/Instant;)V
public final fun setDeafened (Ljava/lang/Boolean;)V
public final fun setFlags (Ldev/kord/common/entity/GuildMemberFlags;)V
public final fun setMuted (Ljava/lang/Boolean;)V
public final fun setNickname (Ljava/lang/String;)V
public fun setReason (Ljava/lang/String;)V
Expand Down Expand Up @@ -4087,21 +4089,23 @@ public final class dev/kord/rest/json/request/GuildMemberAddRequest$Companion {
public final class dev/kord/rest/json/request/GuildMemberModifyRequest {
public static final field Companion Ldev/kord/rest/json/request/GuildMemberModifyRequest$Companion;
public fun <init> ()V
public synthetic fun <init> (ILdev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (ILdev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;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/optional/Optional;
public final fun component2 ()Ldev/kord/common/entity/optional/Optional;
public final fun component3 ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun component4 ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun component5 ()Ldev/kord/common/entity/optional/OptionalSnowflake;
public final fun component6 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/GuildMemberModifyRequest;
public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildMemberModifyRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildMemberModifyRequest;
public final fun component7 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/GuildMemberModifyRequest;
public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildMemberModifyRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildMemberModifyRequest;
public fun equals (Ljava/lang/Object;)Z
public final fun getChannelId ()Ldev/kord/common/entity/optional/OptionalSnowflake;
public final fun getCommunicationDisabledUntil ()Ldev/kord/common/entity/optional/Optional;
public final fun getDeaf ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun getFlags ()Ldev/kord/common/entity/optional/Optional;
public final fun getMute ()Ldev/kord/common/entity/optional/OptionalBoolean;
public final fun getNick ()Ldev/kord/common/entity/optional/Optional;
public final fun getRoles ()Ldev/kord/common/entity/optional/Optional;
Expand Down
Loading