-
Notifications
You must be signed in to change notification settings - Fork 82
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
Implement polls #933
base: main
Are you sure you want to change the base?
Implement polls #933
Changes from 25 commits
61a3c94
18ddf0b
3ee35ec
57d4957
9ea2746
23e450a
8a1b62f
eea7cc3
303c792
e09b4d7
5c394c4
5099335
25053f4
5f32764
a883c08
987969b
65a578f
2a306cd
274cf12
164203b
703b4ff
f25d559
a58879b
3efd971
39fcfb7
abe3347
1ef1433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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 [PollLayoutType]s in the | ||
* [Discord Developer Documentation](https://discord.com/developers/docs/resources/poll#layout-type). | ||
*/ | ||
@Serializable(with = PollLayoutType.Serializer::class) | ||
public sealed class PollLayoutType( | ||
/** | ||
* The raw value used by Discord. | ||
*/ | ||
public val `value`: Int, | ||
) { | ||
final override fun equals(other: Any?): Boolean = this === other || | ||
(other is PollLayoutType && this.value == other.value) | ||
|
||
final override fun hashCode(): Int = value.hashCode() | ||
|
||
final override fun toString(): String = | ||
if (this is Unknown) "PollLayoutType.Unknown(value=$value)" | ||
else "PollLayoutType.${this::class.simpleName}" | ||
|
||
/** | ||
* An unknown [PollLayoutType]. | ||
* | ||
* This is used as a fallback for [PollLayoutType]s that haven't been added to Kord yet. | ||
*/ | ||
public class Unknown internal constructor( | ||
`value`: Int, | ||
) : PollLayoutType(value) | ||
|
||
/** | ||
* The, uhm, default layout type. | ||
*/ | ||
public object Default : PollLayoutType(1) | ||
|
||
internal object Serializer : KSerializer<PollLayoutType> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("dev.kord.common.entity.PollLayoutType", | ||
PrimitiveKind.INT) | ||
|
||
override fun serialize(encoder: Encoder, `value`: PollLayoutType) { | ||
encoder.encodeInt(value.value) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): PollLayoutType = from(decoder.decodeInt()) | ||
} | ||
|
||
public companion object { | ||
/** | ||
* A [List] of all known [PollLayoutType]s. | ||
*/ | ||
public val entries: List<PollLayoutType> by lazy(mode = PUBLICATION) { | ||
listOf( | ||
Default, | ||
) | ||
} | ||
|
||
/** | ||
* Returns an instance of [PollLayoutType] with [PollLayoutType.value] equal to the | ||
* specified [value]. | ||
*/ | ||
public fun from(`value`: Int): PollLayoutType = when (value) { | ||
1 -> Default | ||
else -> Unknown(value) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -308,7 +308,8 @@ public data class InteractionCallbackData( | |||
@SerialName("component_type") | ||||
val componentType: Optional<ComponentType> = Optional.Missing(), | ||||
val values: Optional<List<String>> = Optional.Missing(), | ||||
val components: Optional<List<DiscordComponent>> = Optional.Missing() | ||||
val components: Optional<List<DiscordComponent>> = Optional.Missing(), | ||||
val poll: Optional<DiscordPoll> = Optional.Missing() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
) | ||||
|
||||
@Serializable(with = Option.Serializer::class) | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also be added to
DiscordPartialMessage
to be safe