-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for User installable apps
- Loading branch information
1 parent
a4311db
commit a673908
Showing
30 changed files
with
1,194 additions
and
202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
...rated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationIntegrationType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// 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 | ||
|
||
/** | ||
* Where an app can be installed, also called its supported installation contexts | ||
* | ||
* See [ApplicationIntegrationType]s in the | ||
* [Discord Developer Documentation](https://discord.com/developers/docs/resources/application#application-object-application-integration-types). | ||
*/ | ||
@Serializable(with = ApplicationIntegrationType.Serializer::class) | ||
public sealed class ApplicationIntegrationType( | ||
/** | ||
* The raw value used by Discord. | ||
*/ | ||
public val `value`: Int, | ||
) { | ||
final override fun equals(other: Any?): Boolean = this === other || | ||
(other is ApplicationIntegrationType && this.value == other.value) | ||
|
||
final override fun hashCode(): Int = value.hashCode() | ||
|
||
final override fun toString(): String = | ||
if (this is Unknown) "ApplicationIntegrationType.Unknown(value=$value)" | ||
else "ApplicationIntegrationType.${this::class.simpleName}" | ||
|
||
/** | ||
* An unknown [ApplicationIntegrationType]. | ||
* | ||
* This is used as a fallback for [ApplicationIntegrationType]s that haven't been added to Kord | ||
* yet. | ||
*/ | ||
public class Unknown internal constructor( | ||
`value`: Int, | ||
) : ApplicationIntegrationType(value) | ||
|
||
/** | ||
* App is installable to servers | ||
*/ | ||
public object GuildInstall : ApplicationIntegrationType(0) | ||
|
||
/** | ||
* App is installable to users | ||
*/ | ||
public object UserInstall : ApplicationIntegrationType(0) | ||
|
||
internal object Serializer : KSerializer<ApplicationIntegrationType> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationIntegrationType", | ||
PrimitiveKind.INT) | ||
|
||
override fun serialize(encoder: Encoder, `value`: ApplicationIntegrationType) { | ||
encoder.encodeInt(value.value) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): ApplicationIntegrationType = | ||
from(decoder.decodeInt()) | ||
} | ||
|
||
public companion object { | ||
/** | ||
* A [List] of all known [ApplicationIntegrationType]s. | ||
*/ | ||
public val entries: List<ApplicationIntegrationType> by lazy(mode = PUBLICATION) { | ||
listOf( | ||
GuildInstall, | ||
) | ||
} | ||
|
||
/** | ||
* Returns an instance of [ApplicationIntegrationType] with | ||
* [ApplicationIntegrationType.value] equal to the specified [value]. | ||
*/ | ||
public fun from(`value`: Int): ApplicationIntegrationType = when (value) { | ||
0 -> GuildInstall | ||
else -> Unknown(value) | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionContextType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// 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 | ||
|
||
/** | ||
* Context in Discord where an interaction can be used, or where it was triggered from. | ||
* | ||
* See [InteractionContextType]s in the | ||
* [Discord Developer Documentation](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types). | ||
*/ | ||
@Serializable(with = InteractionContextType.Serializer::class) | ||
public sealed class InteractionContextType( | ||
/** | ||
* The raw value used by Discord. | ||
*/ | ||
public val `value`: Int, | ||
) { | ||
final override fun equals(other: Any?): Boolean = this === other || | ||
(other is InteractionContextType && this.value == other.value) | ||
|
||
final override fun hashCode(): Int = value.hashCode() | ||
|
||
final override fun toString(): String = | ||
if (this is Unknown) "InteractionContextType.Unknown(value=$value)" | ||
else "InteractionContextType.${this::class.simpleName}" | ||
|
||
/** | ||
* An unknown [InteractionContextType]. | ||
* | ||
* This is used as a fallback for [InteractionContextType]s that haven't been added to Kord yet. | ||
*/ | ||
public class Unknown internal constructor( | ||
`value`: Int, | ||
) : InteractionContextType(value) | ||
|
||
/** | ||
* Interaction can be used within servers | ||
*/ | ||
public object Guild : InteractionContextType(0) | ||
|
||
/** | ||
* Interaction can be used within DMs with the app's bot user | ||
*/ | ||
public object BotDM : InteractionContextType(1) | ||
|
||
/** | ||
* Interaction can be used within Group DMs and DMs other than the app's bot user | ||
*/ | ||
public object PrivateChannel : InteractionContextType(2) | ||
|
||
internal object Serializer : KSerializer<InteractionContextType> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionContextType", | ||
PrimitiveKind.INT) | ||
|
||
override fun serialize(encoder: Encoder, `value`: InteractionContextType) { | ||
encoder.encodeInt(value.value) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): InteractionContextType = | ||
from(decoder.decodeInt()) | ||
} | ||
|
||
public companion object { | ||
/** | ||
* A [List] of all known [InteractionContextType]s. | ||
*/ | ||
public val entries: List<InteractionContextType> by lazy(mode = PUBLICATION) { | ||
listOf( | ||
Guild, | ||
BotDM, | ||
PrivateChannel, | ||
) | ||
} | ||
|
||
/** | ||
* Returns an instance of [InteractionContextType] with [InteractionContextType.value] equal | ||
* to the specified [value]. | ||
*/ | ||
public fun from(`value`: Int): InteractionContextType = when (value) { | ||
0 -> Guild | ||
1 -> BotDM | ||
2 -> PrivateChannel | ||
else -> Unknown(value) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.