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 Message.applicationId #289

Merged
merged 1 commit into from
May 14, 2021
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
3 changes: 3 additions & 0 deletions common/src/main/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import kotlin.contracts.contract
* @param flags Message flags.
* @param stickers The stickers sent with the message (bots currently can only receive messages with stickers, not send).
* @param referencedMessage the message associated with [messageReference].
* @param applicationId if the message is a response to an [Interaction][DiscordInteraction], this is the id of the interaction's application
*/
@Serializable
data class DiscordMessage(
Expand Down Expand Up @@ -93,6 +94,8 @@ data class DiscordMessage(
val type: MessageType,
val activity: Optional<MessageActivity> = Optional.Missing(),
val application: Optional<MessageApplication> = Optional.Missing(),
@SerialName("application_id")
val applicationId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("message_reference")
val messageReference: Optional<DiscordMessageReference> = Optional.Missing(),
val flags: Optional<MessageFlags> = Optional.Missing(),
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/kotlin/cache/data/MessageData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ data class MessageData(
val type: MessageType,
val activity: Optional<MessageActivity> = Optional.Missing(),
val application: Optional<MessageApplication> = Optional.Missing(),
val applicationId: OptionalSnowflake = OptionalSnowflake.Missing,
val messageReference: Optional<MessageReferenceData> = Optional.Missing(),
val flags: Optional<MessageFlags> = Optional.Missing(),
val stickers: Optional<List<MessageStickerData>> = Optional.Missing(),
Expand Down Expand Up @@ -92,6 +93,7 @@ data class MessageData(
type,
activity,
application,
applicationId,
messageReference,
flags,
stickers = stickers,
Expand Down Expand Up @@ -124,6 +126,7 @@ data class MessageData(
type,
activity,
application,
applicationId,
messageReference.map { MessageReferenceData.from(it) },
flags,
stickers.mapList { MessageStickerData.from(it) },
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/kotlin/entity/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dev.kord.core.entity.channel.Channel
import dev.kord.core.entity.channel.GuildChannel
import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.Interaction
import dev.kord.core.exception.EntityNotFoundException
import dev.kord.core.supplier.EntitySupplier
import dev.kord.core.supplier.EntitySupplyStrategy
Expand Down Expand Up @@ -102,6 +103,11 @@ class Message(
*/
val stickers: List<MessageSticker> get() = data.stickers.orEmpty().map { MessageSticker(it, kord) }

/**
* If the message is a response to an [Interaction], this is the id of the interaction's application
*/
val applicationId: Snowflake? get() = data.applicationId.value

/**
* The message being replied to.
*
Expand Down