Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/user-apps' into mikbot
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/api/core.api
#	core/api/core.klib.api
  • Loading branch information
DRSchlaubi committed Nov 8, 2024
2 parents 9be6f34 + 8660e92 commit 3889ffa
Show file tree
Hide file tree
Showing 104 changed files with 2,011 additions and 204 deletions.
319 changes: 268 additions & 51 deletions common/api/common.api

Large diffs are not rendered by default.

331 changes: 275 additions & 56 deletions common/api/common.klib.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public sealed class ApplicationCommandType(
*/
public object Message : ApplicationCommandType(3)

/**
* A UI-based command that represents the primary way to invoke an app's
* [Activity](https://discord.com/developers/docs/activities/overview)
*/
public object PrimaryEntryPoint : ApplicationCommandType(4)

internal object Serializer : KSerializer<ApplicationCommandType> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandType",
Expand All @@ -79,6 +85,7 @@ public sealed class ApplicationCommandType(
ChatInput,
User,
Message,
PrimaryEntryPoint,
)
}

Expand All @@ -90,6 +97,7 @@ public sealed class ApplicationCommandType(
1 -> ChatInput
2 -> User
3 -> Message
4 -> PrimaryEntryPoint
else -> Unknown(value)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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(1)

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,
UserInstall,
)
}

/**
* Returns an instance of [ApplicationIntegrationType] with
* [ApplicationIntegrationType.value] equal to the specified [value].
*/
public fun from(`value`: Int): ApplicationIntegrationType = when (value) {
0 -> GuildInstall
1 -> UserInstall
else -> Unknown(value)
}
}
}
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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public sealed class InteractionResponseType(
*/
public object Modal : InteractionResponseType(9)

/**
* Launch the Activity associated with the app. Only available for apps with Activities enabled
*/
public object LaunchActivity : InteractionResponseType(12)

internal object Serializer : KSerializer<InteractionResponseType> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionResponseType",
Expand All @@ -105,6 +110,7 @@ public sealed class InteractionResponseType(
UpdateMessage,
ApplicationCommandAutoCompleteResult,
Modal,
LaunchActivity,
)
}

Expand All @@ -120,6 +126,7 @@ public sealed class InteractionResponseType(
7 -> UpdateMessage
8 -> ApplicationCommandAutoCompleteResult
9 -> Modal
12 -> LaunchActivity
else -> Unknown(type)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ public sealed class Permission(
*/
public object SendVoiceMessages : Permission(46)

/**
* Allows user-installed apps to send public responses. When disabled, users will still be
* allowed to use their apps but the responses will be ephemeral. This only applies to apps not
* also installed to the server.
*/
public object USE_EXTERNAL_APPS : Permission(50)

public companion object {
/**
* A [List] of all known [Permission]s.
Expand Down Expand Up @@ -365,6 +372,7 @@ public sealed class Permission(
CreateEvents,
UseExternalSounds,
SendVoiceMessages,
USE_EXTERNAL_APPS,
)
}

Expand Down Expand Up @@ -422,6 +430,7 @@ public sealed class Permission(
44 -> CreateEvents
45 -> UseExternalSounds
46 -> SendVoiceMessages
50 -> USE_EXTERNAL_APPS
else -> Unknown(shift)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// 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 [PrimaryEntryPointCommandHandlerType]s in the
* [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-object-entry-point-command-handler-types).
*/
@Serializable(with = PrimaryEntryPointCommandHandlerType.Serializer::class)
public sealed class PrimaryEntryPointCommandHandlerType(
/**
* The raw value used by Discord.
*/
public val `value`: Int,
) {
final override fun equals(other: Any?): Boolean = this === other ||
(other is PrimaryEntryPointCommandHandlerType && this.value == other.value)

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

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

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

/**
* The app handles the interaction using an interaction token
*/
public object AppHandler : PrimaryEntryPointCommandHandlerType(1)

/**
* Discord handles the interaction by launching an Activity and sending a follow-up message
* without coordinating with the app
*/
public object DiscordLaunchActivity : PrimaryEntryPointCommandHandlerType(2)

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

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

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

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

/**
* Returns an instance of [PrimaryEntryPointCommandHandlerType] with
* [PrimaryEntryPointCommandHandlerType.value] equal to the specified [value].
*/
public fun from(`value`: Int): PrimaryEntryPointCommandHandlerType = when (value) {
1 -> AppHandler
2 -> DiscordLaunchActivity
else -> Unknown(value)
}
}
}
Loading

0 comments on commit 3889ffa

Please sign in to comment.