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 support for Message forwarding #972

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
79 changes: 68 additions & 11 deletions common/api/common.api

Large diffs are not rendered by default.

87 changes: 73 additions & 14 deletions common/api/common.klib.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))

package dev.kord.common.entity

import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [MessageReferenceType]s in the
* [Discord Developer Documentation](https://discord.com/developers/docs/resources/message#message-reference-structure).
*/
@Serializable(with = MessageReferenceType.Serializer::class)
public sealed class MessageReferenceType(
/**
* The raw value used by Discord.
*/
public val `value`: Int,
) {
final override fun equals(other: Any?): Boolean = this === other ||
(other is MessageReferenceType && this.value == other.value)

final override fun hashCode(): Int = value.hashCode()

final override fun toString(): String =
if (this is Unknown) "MessageReferenceType.Unknown(value=$value)"
else "MessageReferenceType.${this::class.simpleName}"

/**
* An unknown [MessageReferenceType].
*
* This is used as a fallback for [MessageReferenceType]s that haven't been added to Kord yet.
*/
public class Unknown internal constructor(
`value`: Int,
) : MessageReferenceType(value)

/**
* A standard reference used by replies.
*/
public object Default : MessageReferenceType(0)

/**
* Reference used to point to a message at a point in time.
*/
public object Forward : MessageReferenceType(1)

internal object Serializer : KSerializer<MessageReferenceType> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.MessageReferenceType",
PrimitiveKind.INT)

override fun serialize(encoder: Encoder, `value`: MessageReferenceType) {
encoder.encodeInt(value.value)
}

override fun deserialize(decoder: Decoder): MessageReferenceType = from(decoder.decodeInt())
}

public companion object {
/**
* A [List] of all known [MessageReferenceType]s.
*/
public val entries: List<MessageReferenceType> by lazy(mode = PUBLICATION) {
listOf(
Default,
Forward,
)
}

/**
* Returns an instance of [MessageReferenceType] with [MessageReferenceType.value] equal to
* the specified [value].
*/
public fun from(`value`: Int): MessageReferenceType = when (value) {
0 -> Default
1 -> Forward
else -> Unknown(value)
}
}
}
14 changes: 14 additions & 0 deletions common/src/commonMain/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
],
)

@file:Generate(
INT_KORD_ENUM, name = "MessageReferenceType",
docUrl = "https://discord.com/developers/docs/resources/message#message-reference-structure",
entries = [
Entry("Default", intValue = 0, kDoc = "A standard reference used by replies."),
Entry("Forward", intValue = 1, kDoc = "Reference used to point to a message at a point in time."),
]
)

package dev.kord.common.entity

import dev.kord.common.entity.optional.Optional
Expand Down Expand Up @@ -221,6 +230,7 @@ public data class DiscordMessage(
val applicationId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("message_reference")
val messageReference: Optional<DiscordMessageReference> = Optional.Missing(),
val messageSnapshots: Optional<List<DiscordMessageSnapshot>> = Optional.Missing(),
val flags: Optional<MessageFlags> = Optional.Missing(),
@SerialName("sticker_items")
val stickers: Optional<List<DiscordStickerItem>> = Optional.Missing(),
Expand Down Expand Up @@ -376,6 +386,7 @@ public data class DiscordPartialMessage(

@Serializable
public data class DiscordMessageReference(
val type: Optional<MessageReferenceType> = Optional.Missing(),
@SerialName("message_id")
val id: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("channel_id")
Expand All @@ -386,6 +397,9 @@ public data class DiscordMessageReference(
val failIfNotExists: OptionalBoolean = OptionalBoolean.Missing
)

@Serializable
public data class DiscordMessageSnapshot(val message: DiscordMessage)

/**
* A representation of a [Discord Channel Mention structure](https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure).
*
Expand Down
56 changes: 51 additions & 5 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -4260,8 +4260,8 @@ public final class dev/kord/core/cache/data/MembersChunkData$Companion {

public final class dev/kord/core/cache/data/MessageData {
public static final field Companion Ldev/kord/core/cache/data/MessageData$Companion;
public fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;)V
public synthetic fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;)V
public synthetic fun <init> (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/kord/common/entity/Snowflake;
public final fun component10 ()Ljava/util/List;
public final fun component11 ()Ljava/util/List;
Expand All @@ -4285,15 +4285,16 @@ public final class dev/kord/core/cache/data/MessageData {
public final fun component28 ()Ldev/kord/common/entity/optional/Optional;
public final fun component29 ()Ldev/kord/common/entity/optional/Optional;
public final fun component3 ()Ldev/kord/common/entity/optional/OptionalSnowflake;
public final fun component30 ()Ldev/kord/common/entity/optional/OptionalInt;
public final fun component30 ()Ldev/kord/common/entity/optional/Optional;
public final fun component31 ()Ldev/kord/common/entity/optional/OptionalInt;
public final fun component4 ()Ldev/kord/core/cache/data/UserData;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Lkotlinx/datetime/Instant;
public final fun component7 ()Lkotlinx/datetime/Instant;
public final fun component8 ()Z
public final fun component9 ()Z
public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;)Ldev/kord/core/cache/data/MessageData;
public static synthetic fun copy$default (Ldev/kord/core/cache/data/MessageData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;ILjava/lang/Object;)Ldev/kord/core/cache/data/MessageData;
public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;)Ldev/kord/core/cache/data/MessageData;
public static synthetic fun copy$default (Ldev/kord/core/cache/data/MessageData;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/core/cache/data/UserData;Ljava/lang/String;Lkotlinx/datetime/Instant;Lkotlinx/datetime/Instant;ZZLjava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ljava/util/List;Ljava/util/List;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ZLdev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/MessageType;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalSnowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;ILjava/lang/Object;)Ldev/kord/core/cache/data/MessageData;
public fun equals (Ljava/lang/Object;)Z
public final fun getActivity ()Ldev/kord/common/entity/optional/Optional;
public final fun getApplication ()Ldev/kord/common/entity/optional/Optional;
Expand All @@ -4314,6 +4315,7 @@ public final class dev/kord/core/cache/data/MessageData {
public final fun getMentionedChannels ()Ldev/kord/common/entity/optional/Optional;
public final fun getMentions ()Ljava/util/List;
public final fun getMessageReference ()Ldev/kord/common/entity/optional/Optional;
public final fun getMessageSnapshots ()Ldev/kord/common/entity/optional/Optional;
public final fun getNonce ()Ldev/kord/common/entity/optional/Optional;
public final fun getPinned ()Z
public final fun getPosition ()Ldev/kord/common/entity/optional/OptionalInt;
Expand Down Expand Up @@ -4420,6 +4422,34 @@ public final class dev/kord/core/cache/data/MessageReferenceData$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/core/cache/data/MessageSnapshotData {
public static final field Companion Ldev/kord/core/cache/data/MessageSnapshotData$Companion;
public fun <init> (Ldev/kord/core/cache/data/MessageData;)V
public final fun component1 ()Ldev/kord/core/cache/data/MessageData;
public final fun copy (Ldev/kord/core/cache/data/MessageData;)Ldev/kord/core/cache/data/MessageSnapshotData;
public static synthetic fun copy$default (Ldev/kord/core/cache/data/MessageSnapshotData;Ldev/kord/core/cache/data/MessageData;ILjava/lang/Object;)Ldev/kord/core/cache/data/MessageSnapshotData;
public fun equals (Ljava/lang/Object;)Z
public final fun getMessage ()Ldev/kord/core/cache/data/MessageData;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public synthetic class dev/kord/core/cache/data/MessageSnapshotData$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/kord/core/cache/data/MessageSnapshotData$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/core/cache/data/MessageSnapshotData;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/kord/core/cache/data/MessageSnapshotData;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/core/cache/data/MessageSnapshotData$Companion {
public final fun from (Ldev/kord/common/entity/DiscordMessageSnapshot;)Ldev/kord/core/cache/data/MessageSnapshotData;
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/core/cache/data/NotSerializable : kotlinx/serialization/KSerializer {
public static final field INSTANCE Ldev/kord/core/cache/data/NotSerializable;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
Expand Down Expand Up @@ -6583,6 +6613,7 @@ public final class dev/kord/core/entity/Message : dev/kord/core/behavior/Message
public final fun getMentionedUsers ()Lkotlinx/coroutines/flow/Flow;
public final fun getMentionsEveryone ()Z
public final fun getMessageReference ()Ldev/kord/core/entity/MessageReference;
public final fun getMessageSnapshots ()Ljava/util/List;
public final fun getPosition ()Ljava/lang/Integer;
public final fun getReactions ()Ljava/util/Set;
public fun getReactors (Ldev/kord/core/entity/ReactionEmoji;)Lkotlinx/coroutines/flow/Flow;
Expand Down Expand Up @@ -6632,6 +6663,21 @@ public final class dev/kord/core/entity/MessageReference : dev/kord/core/KordObj
public final fun getMessage ()Ldev/kord/core/behavior/MessageBehavior;
}

public final class dev/kord/core/entity/MessageSnapshot : dev/kord/core/KordObject {
public fun <init> (Ldev/kord/core/cache/data/MessageSnapshotData;Ldev/kord/core/Kord;)V
public final fun getAttachments ()Ljava/util/List;
public final fun getContent ()Ljava/lang/String;
public final fun getData ()Ldev/kord/core/cache/data/MessageSnapshotData;
public final fun getEditedTimestamp ()Lkotlinx/datetime/Instant;
public final fun getEmbeds ()Ljava/util/List;
public final fun getFlags ()Ldev/kord/common/entity/MessageFlags;
public fun getKord ()Ldev/kord/core/Kord;
public final fun getMentionRoles ()Ljava/util/List;
public final fun getMentions ()Ljava/util/List;
public final fun getTimestamp ()Lkotlinx/datetime/Instant;
public final fun getType ()Ldev/kord/common/entity/MessageType;
}

public final class dev/kord/core/entity/PartialApplication : dev/kord/core/entity/BaseApplication {
public fun <init> (Ldev/kord/core/cache/data/PartialApplicationData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;)V
public synthetic fun <init> (Ldev/kord/core/cache/data/PartialApplicationData;Ldev/kord/core/Kord;Ldev/kord/core/supplier/EntitySupplier;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Loading