Skip to content

Commit

Permalink
Add Message.applicationId (kordlib#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed May 26, 2021
1 parent f1c2bf8 commit e300c5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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

0 comments on commit e300c5b

Please sign in to comment.