diff --git a/common/api/common.api b/common/api/common.api index 82bc57e62ff..ae399e5c44c 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -202,6 +202,8 @@ public abstract class dev/kord/common/entity/ActivityFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/ActivityFlag;)Ldev/kord/common/entity/ActivityFlags; + public final fun plus (Ldev/kord/common/entity/ActivityFlags;)Ldev/kord/common/entity/ActivityFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/ActivityFlag; public static fun values ()[Ldev/kord/common/entity/ActivityFlag; @@ -638,6 +640,8 @@ public abstract class dev/kord/common/entity/ApplicationFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/ApplicationFlag;)Ldev/kord/common/entity/ApplicationFlags; + public final fun plus (Ldev/kord/common/entity/ApplicationFlags;)Ldev/kord/common/entity/ApplicationFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/ApplicationFlag; public static fun values ()[Ldev/kord/common/entity/ApplicationFlag; @@ -6727,6 +6731,8 @@ public abstract class dev/kord/common/entity/GuildMemberFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/GuildMemberFlag;)Ldev/kord/common/entity/GuildMemberFlags; + public final fun plus (Ldev/kord/common/entity/GuildMemberFlags;)Ldev/kord/common/entity/GuildMemberFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/GuildMemberFlag; public static fun values ()[Ldev/kord/common/entity/GuildMemberFlag; @@ -7298,6 +7304,8 @@ public abstract class dev/kord/common/entity/MessageFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/MessageFlag;)Ldev/kord/common/entity/MessageFlags; + public final fun plus (Ldev/kord/common/entity/MessageFlags;)Ldev/kord/common/entity/MessageFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/MessageFlag; public static fun values ()[Ldev/kord/common/entity/MessageFlag; @@ -7804,6 +7812,8 @@ public abstract class dev/kord/common/entity/Permission { public final fun equals (Ljava/lang/Object;)Z public final fun getCode ()Ldev/kord/common/DiscordBitSet; public final fun hashCode ()I + public final fun plus (Ldev/kord/common/entity/Permission;)Ldev/kord/common/entity/Permissions; + public final fun plus (Ldev/kord/common/entity/Permissions;)Ldev/kord/common/entity/Permissions; public final fun toString ()Ljava/lang/String; } @@ -8396,6 +8406,8 @@ public abstract class dev/kord/common/entity/SystemChannelFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/SystemChannelFlag;)Ldev/kord/common/entity/SystemChannelFlags; + public final fun plus (Ldev/kord/common/entity/SystemChannelFlags;)Ldev/kord/common/entity/SystemChannelFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/SystemChannelFlag; public static fun values ()[Ldev/kord/common/entity/SystemChannelFlag; @@ -8559,6 +8571,8 @@ public abstract class dev/kord/common/entity/UserFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/common/entity/UserFlag;)Ldev/kord/common/entity/UserFlags; + public final fun plus (Ldev/kord/common/entity/UserFlags;)Ldev/kord/common/entity/UserFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/common/entity/UserFlag; public static fun values ()[Ldev/kord/common/entity/UserFlag; diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ActivityFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ActivityFlag.kt index 6d2e29a0d58..8709716b011 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ActivityFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ActivityFlag.kt @@ -181,6 +181,12 @@ public sealed class ActivityFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: ActivityFlag): ActivityFlags = + ActivityFlags(this.code or flag.code) + + public operator fun plus(flags: ActivityFlags): ActivityFlags = + ActivityFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is ActivityFlag && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationFlag.kt index 2c0a8213c8c..543bf5fc155 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationFlag.kt @@ -204,6 +204,12 @@ public sealed class ApplicationFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: ApplicationFlag): ApplicationFlags = + ApplicationFlags(this.code or flag.code) + + public operator fun plus(flags: ApplicationFlags): ApplicationFlags = + ApplicationFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is ApplicationFlag && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildMemberFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildMemberFlag.kt index 62e08794367..ccc2d887362 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildMemberFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildMemberFlag.kt @@ -203,6 +203,12 @@ public sealed class GuildMemberFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: GuildMemberFlag): GuildMemberFlags = + GuildMemberFlags(this.code or flag.code) + + public operator fun plus(flags: GuildMemberFlags): GuildMemberFlags = + GuildMemberFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is GuildMemberFlag && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageFlag.kt index a1a0287c906..c935e4e9845 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageFlag.kt @@ -197,6 +197,11 @@ public sealed class MessageFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: MessageFlag): MessageFlags = MessageFlags(this.code or flag.code) + + public operator fun plus(flags: MessageFlags): MessageFlags = + MessageFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is MessageFlag && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/Permission.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/Permission.kt index 753b83484d7..c260cd75c91 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/Permission.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/Permission.kt @@ -196,6 +196,10 @@ public sealed class Permission { this.code = code } + public operator fun plus(flag: Permission): Permissions = Permissions(this.code + flag.code) + + public operator fun plus(flags: Permissions): Permissions = Permissions(this.code + flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is Permission && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SystemChannelFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SystemChannelFlag.kt index 7dbf38ee625..d917be0fe36 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SystemChannelFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SystemChannelFlag.kt @@ -205,6 +205,12 @@ public sealed class SystemChannelFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: SystemChannelFlag): SystemChannelFlags = + SystemChannelFlags(this.code or flag.code) + + public operator fun plus(flags: SystemChannelFlags): SystemChannelFlags = + SystemChannelFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is SystemChannelFlag && this.code == other.code) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserFlag.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserFlag.kt index a60f25b10bd..fd27a7ae259 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserFlag.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserFlag.kt @@ -189,6 +189,10 @@ public sealed class UserFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: UserFlag): UserFlags = UserFlags(this.code or flag.code) + + public operator fun plus(flags: UserFlags): UserFlags = UserFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is UserFlag && this.code == other.code) diff --git a/gateway/api/gateway.api b/gateway/api/gateway.api index 62941e8bcd0..559d83b72c2 100644 --- a/gateway/api/gateway.api +++ b/gateway/api/gateway.api @@ -1201,6 +1201,8 @@ public abstract class dev/kord/gateway/Intent { public final fun equals (Ljava/lang/Object;)Z public final fun getCode ()Ldev/kord/common/DiscordBitSet; public final fun hashCode ()I + public final fun plus (Ldev/kord/gateway/Intent;)Ldev/kord/gateway/Intents; + public final fun plus (Ldev/kord/gateway/Intents;)Ldev/kord/gateway/Intents; public final fun toString ()Ljava/lang/String; } diff --git a/gateway/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/gateway/Intent.kt b/gateway/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/gateway/Intent.kt index 4f998b696b4..d8656a615ee 100644 --- a/gateway/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/gateway/Intent.kt +++ b/gateway/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/gateway/Intent.kt @@ -187,6 +187,10 @@ public sealed class Intent( */ public val code: DiscordBitSet = EmptyBitSet().also { it[shift] = true } + public operator fun plus(flag: Intent): Intents = Intents(this.code + flag.code) + + public operator fun plus(flags: Intents): Intents = Intents(this.code + flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is Intent && this.code == other.code) diff --git a/ksp-processors/src/main/kotlin/generation/bitflags/BitFlagsGeneration.kt b/ksp-processors/src/main/kotlin/generation/bitflags/BitFlagsGeneration.kt index 59491811c64..0f41f26398f 100644 --- a/ksp-processors/src/main/kotlin/generation/bitflags/BitFlagsGeneration.kt +++ b/ksp-processors/src/main/kotlin/generation/bitflags/BitFlagsGeneration.kt @@ -155,6 +155,30 @@ internal fun BitFlags.generateFileSpec(originatingFile: KSFile) = fileSpecForGen } } } + addFunction("plus") { + addModifiers(PUBLIC, OPERATOR) + addParameter("flag", entityCN) + returns(collectionName) + addStatement( + when (valueType) { + INT -> "return %T(this.code·or·flag.code)" + BIT_SET -> "return %T(this.code·+·flag.code)" + }, + collectionName, + ) + } + addFunction("plus") { + addModifiers(PUBLIC, OPERATOR) + addParameter("flags", collectionName) + returns(collectionName) + addStatement( + when (valueType) { + INT -> "return %T(this.code·or·flags.code)" + BIT_SET -> "return %T(this.code·+·flags.code)" + }, + collectionName, + ) + } addEntityEqualsHashCodeToString() if (wasEnum) { addDeprecatedEntityEnumArtifacts() diff --git a/voice/api/voice.api b/voice/api/voice.api index 3efc940dc3c..8fa5b61e735 100644 --- a/voice/api/voice.api +++ b/voice/api/voice.api @@ -257,6 +257,8 @@ public abstract class dev/kord/voice/SpeakingFlag { public final fun hashCode ()I public final fun name ()Ljava/lang/String; public final fun ordinal ()I + public final fun plus (Ldev/kord/voice/SpeakingFlag;)Ldev/kord/voice/SpeakingFlags; + public final fun plus (Ldev/kord/voice/SpeakingFlags;)Ldev/kord/voice/SpeakingFlags; public final fun toString ()Ljava/lang/String; public static fun valueOf (Ljava/lang/String;)Ldev/kord/voice/SpeakingFlag; public static fun values ()[Ldev/kord/voice/SpeakingFlag; diff --git a/voice/build/generated/ksp/main/kotlin/dev/kord/voice/SpeakingFlag.kt b/voice/build/generated/ksp/main/kotlin/dev/kord/voice/SpeakingFlag.kt index 1fb3b37b5a8..068b641f187 100644 --- a/voice/build/generated/ksp/main/kotlin/dev/kord/voice/SpeakingFlag.kt +++ b/voice/build/generated/ksp/main/kotlin/dev/kord/voice/SpeakingFlag.kt @@ -181,6 +181,12 @@ public sealed class SpeakingFlag( */ public val code: Int = 1 shl shift + public operator fun plus(flag: SpeakingFlag): SpeakingFlags = + SpeakingFlags(this.code or flag.code) + + public operator fun plus(flags: SpeakingFlags): SpeakingFlags = + SpeakingFlags(this.code or flags.code) + final override fun equals(other: Any?): Boolean = this === other || (other is SpeakingFlag && this.code == other.code)