-
Notifications
You must be signed in to change notification settings - Fork 626
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
Handle empty String as null #678
Comments
@hfhbd There is also the option to use a custom serializer that does this. It allows much more fine-grained control. |
I know, but writing a custom serializer for classes containing 50 or more attributes is a little bit "annoying". Its not possible to get the generated KSerializer from the compiler as kotlin source code, is it? This would eliminate the manual boilerplate code. |
@hfhbd I don't mean a custom serializer for the class that owns the string. I mean a custom serializer for (nullable) strings. Something like: class ABigClassWithManyProperties {
@SerializeWith(NullableStringSerializer::class)
var nullableStringPropertly: String? = null
}
class NullableStringSerializer: KSerializer<String?> {
private val delegate = NullableSerialzier(StringSerializer())
fun serialize(encoder: Encoder, value: String?) {
if (value?.isEmpty()==true) {
delegate.serialize(encoder,null)
} else {
delegate.serialize(encoder,value)
}
}
fun deserialize(decoder:Decoder): String? {
val str = delegate.deserialize(decoder)
if (str?.isEmpty()==true) return null
return str
}
} |
@pdvrieze |
@hfhbd I am not 100% what you mean. However you can add the |
The api sends
How to call this in |
I notice it's been replaced by I've been trying to implement similar to what @pdvrieze implemented here but every time I construct with a
|
You now just use the |
@hfhbd I'm running into the same problem (with ServiceNow API). Could you share a solution if you found one? |
@ddelegator I used my workaround /**
* Workaround to eliminate the usage of a custom serializer, which is not nice with a class containing many members
*/
@Serializable
data class Invalide(@SerialName("content") private var value: String) {
var content: Long?
get() = value.toLongOrNull()
set(newValue) {
this.value = (newValue ?: "").toString()
}
} |
Another Problem is that e.g. the Discord API sometimes just returns an empty string as the entire response and currently there is no way of parsing that response properly as the The way we solved this before is just catching the error any decode method would throw when trying to decode an empty string,
|
- Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test
- Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test
- Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test
- Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test
- Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test
* Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test
@DRSchlaubi you can always do |
I can't here because the exception gets thrown outside the serializer |
@DRSchlaubi This could be handled by the format, by special casing a lack of input (if given a nullable serializer - generated serializers are not nullable, but can be wrapped to be nullable), but it is perhaps something to do as a wrapper (or a wrapper format). |
* Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]>
* Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (kordlib#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (kordlib#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (kordlib#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (kordlib#290) * Update Kotlin 1.5 branch to upstream (kordlib#292) * Implement voice stage channel (kordlib#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix kordlib#270) (kordlib#272) * Make Updatestatus activities not-null (kordlib#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (kordlib#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (kordlib#280) * Expose the creation of application commands behavior (kordlib#281) * Fix GuildUpdate core handling (kordlib#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (kordlib#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (kordlib#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (kordlib#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (kordlib#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (kordlib#293) * Migrate to kotlinx-datetime (kordlib#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (kordlib#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]>
* Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]>
* Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]>
* Ci tests improvement (#264) * allow running dokkaHtml on push * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * close InputStreams used for attachments (#309) * Ephemeral embed support (#296) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * Common builders for interaction response needs more work * Common builders for interaction response needs more work * Seal base builders for interaction response * make embeds list final * make allowedMentions additive * Fix tests * revert tests * Fix stream closed exception I still haven't managed to know the root of the problem but changing the append process fixed it... * use readBytes for Java 8 compatibility * Interaction create improvements (#294) * Expose the creation of application commands behavior * make message type sealed * Fix typo * document interaction create event * apply suggestions and add more details * replace the quotes * proper grammar, Hope * Improve slash command API and add support for components (#310) * Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * interaction code cleanup (#312) * clean up * clean up builders * remove content parameter * Apply suggestions * Make serialization of Snowflake consistent (#316) Snowflakes are decoded as Longs but encoded as Strings. Mixing these types is allowed in JSON (and is done by Discord quite frequently) but does lead to other encoding types failing. This commit changes snowflakes to be encoded and decoded as long values exclusively, and should fix the issue. * Add missing components (#318) * clean up * Add missing component builders * expose default permission * cosmetic changes * add missing overrides * remove actionRow from public interaction response builder * Apply formatting suggestion Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Guild nsfw level (#320) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * add NsfwLevel * update docs [ci skip] * clean up * Fix documentation Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Add non-builder editMessage overload (#323) * Fix followups method signiture (#321) * Fix followups * rename followup functions * Improve live entity life cycle (#315) * fix: Resolve issue about the onShutDown function for Live entities Add deprecated annotation on previous onShutDown extension method Add onShutDown value in LiveEntity to apply action in event or manual case of shutdown * feat: Use coroutine dispatcher for lifecycle of live entity classes Manage the interception of events with the lifecycle of the Live entity. * feat: Use default dispatcher in constructor of live entity * chore: Remove deprecated annotation on onShutDown methods * use and extract SupervisorJob where possible * allow handling a live entity completion * Add structured concurrency to live entity (#285) * test: Begin test for LiveMessage * test: Add tests for LiveMessage class Add tests for listen events Ignore tests where the lifecycle is break by event * chore: Remove useless imports * fix: shutdown action for live entity Deprecate the listening where the live entity is shutdown because the methods are never called Create a property to apply action when the entity is shutdown * fix: Cancel live entity when kord is cancel Add parent of coroutine in constructor of AbstractLiveKordEntity to automatically cancelled the live entity when kord is cancelled * fix: Resolve issue listening for onShutdown, chore: Refactor name shutdown Rename shutDown method to shudown to agree with the method shutdown in kord Resolve issue to listening event for onShutdown action with an empty action job * test: Add abstract class to tests live entity * test: Add tests for abstract live entity and general behavior * chore: Add generic type live entity in abstract class test * chore: Deprecate onCreate method never called by entity * test: Add tests for Member, Role and User live entity Add tests for LiveMember Add tests for LiveRole Add tests for LiveUser * feat: Support BanAddEvent in live guild * test: Change test classes to simulate event and manage it * chore: Remove annotation need token bot * chore: Adapt Role & User live test with send manual event * chore: Adapt Role & User live test with send manual event * test: Add check equality field of event, implements member live test * chore: Remove optIn no used * fix: Correction tests to send fake event instead of real interaction * test: Refactor test to build test with valid and random id * fix: Fix flow issue with delay .. * fix: Rename package to resolve gradle issue I don't know why * test: Add Atomic counter to test event * test: End tests for guild live entity * chore: Place deprecated annotation on live entity Place Deprecated annotation for create event * test: Live category test * chore: Use sequence random id from other tests * test: Tests for all live entities category * test: Add Integrations update for guild live entity * fix: Add delay between creation job and send event Apply a delay between creation jobs and send events to be sure that all jobs are ready to listen the events in flow Without that, this is possible that the test failed * chore: Add deprecated annotation on GuildCreateEvent for live channel * fix: Use guild test channel type (according to GuildMessageChannel) * chore: format * chore: change package name and function name * chore: Use randomID, refactor send event * chore: Doc about shutdown action * chore: Change ReplaceWith in Deprecated annotation, rename shutdown method to shutDown * fix: Remove shutdown action property Remove the onShutDownAction and shutdownAction property to exploit the function invokeOnCompletion from job. Change constructor of live entity to be able to set final the kord instance and launch event in the scope of the live entity * feat: Add cause of shut down live entity * chore: Set deprecate level to Error * test: Add test for LiveGuild with method onGuildCreate * chore: Rename method about completion of job * feat: Add cancellation exception class for live entity Add the class LiveCancellationException to be able to retrieve the event causing the completion of live entity * feat: Add cause of cancellation to retrieve event for each live entity Use the LiveCancellationException class in parameter of shutDown method to be able to retrieve the source event for each live entity * chore: format * tests: Remove delay and use queue to manage action Remove delay between event and replace by Queue to send event when the previous event is received * tests: Add tests for LiveCancellationException constructor Check if there is an error when the exception is called with or not reason message * chore: Refactor property of LiveCancellationException * fix: Null pointer in live entities tests Remove job property, remove delay to use kord.launch and invoke the first event only when the job is ready * chore: try to add delay in tests Add delay in test to help CI * chore: Create constante for delay time in tests * chore: try old system for tests with CI * fix: Remove non-existent code * Retry github action * tests: Check data event caused shutDown Check the data into the event causing the shutDown of the live entity * Retry github action * Retry github action * Retry github action * chore: Change sentence in deprecated annotation * chore: Remove replaceWith Remove replaceWith where the code cannot be correctly generated without instance of object * chore: Homogenize cancel message * chore: Fix imports and ReplaceWith for Deprecated annotation * chore: Remove ReplaceWith for forgotten Deprecated annotation * Fix duplicate update on live entitites (#298) * fix: Resolve issue about several call update function Use the default job children in live entity to call once times the update function * chore: Remove inline doc in test * fix: Use ShareFlow to manage update method * Retry github action * chore: format * Retry github action * feat: Add possibility to define Job parent to create live entities (#304) * feat: Add possibility to define Job parent to create live entities * fix: Use CoroutineScope to define parent * feat: Allows to set CoroutineScope for each method 'on' * feat: Set coroutineScope into constructor of Live entities Change the parameters of AbstractLiveKordEntity to use coroutineScope by delegation * Reload Github workflow * fix: Use kord.coroutineContext to build default CoroutineScope for live entities * Fix compilation issues * tests: Remove test file (#319) * inline supervisor job Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]> * 0.7.0: Update Readme/Changelog (#314) * clean up * update changelog: 0.7.0 * add dependencies * remove copy paste left-overs * Update maven central badge (#267) * improve readme and changelog * remove the dashes * use h2 for changes * Add #304 to the changelog * update changelog * api dump Co-authored-by: Michael Rittmeister <[email protected]> * Add components to webhook builders (#324) * Add components to webhook builders This adds component fields and DSLs to webhook message builders * Fix webhook builders allowed_mentions SerialName * update readme * api dump Co-authored-by: BartArys <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: SirNapkin1334 <[email protected]> Co-authored-by: qbosst <[email protected]> Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]>
* Ci tests improvement (#264) * allow running dokkaHtml on push * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * close InputStreams used for attachments (#309) * Ephemeral embed support (#296) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * Common builders for interaction response needs more work * Common builders for interaction response needs more work * Seal base builders for interaction response * make embeds list final * make allowedMentions additive * Fix tests * revert tests * Fix stream closed exception I still haven't managed to know the root of the problem but changing the append process fixed it... * use readBytes for Java 8 compatibility * Interaction create improvements (#294) * Expose the creation of application commands behavior * make message type sealed * Fix typo * document interaction create event * apply suggestions and add more details * replace the quotes * proper grammar, Hope * Improve slash command API and add support for components (#310) * Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * interaction code cleanup (#312) * clean up * clean up builders * remove content parameter * Apply suggestions * Make serialization of Snowflake consistent (#316) Snowflakes are decoded as Longs but encoded as Strings. Mixing these types is allowed in JSON (and is done by Discord quite frequently) but does lead to other encoding types failing. This commit changes snowflakes to be encoded and decoded as long values exclusively, and should fix the issue. * Add missing components (#318) * clean up * Add missing component builders * expose default permission * cosmetic changes * add missing overrides * remove actionRow from public interaction response builder * Apply formatting suggestion Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Guild nsfw level (#320) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * add NsfwLevel * update docs [ci skip] * clean up * Fix documentation Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Add non-builder editMessage overload (#323) * Fix followups method signiture (#321) * Fix followups * rename followup functions * Improve live entity life cycle (#315) * fix: Resolve issue about the onShutDown function for Live entities Add deprecated annotation on previous onShutDown extension method Add onShutDown value in LiveEntity to apply action in event or manual case of shutdown * feat: Use coroutine dispatcher for lifecycle of live entity classes Manage the interception of events with the lifecycle of the Live entity. * feat: Use default dispatcher in constructor of live entity * chore: Remove deprecated annotation on onShutDown methods * use and extract SupervisorJob where possible * allow handling a live entity completion * Add structured concurrency to live entity (#285) * test: Begin test for LiveMessage * test: Add tests for LiveMessage class Add tests for listen events Ignore tests where the lifecycle is break by event * chore: Remove useless imports * fix: shutdown action for live entity Deprecate the listening where the live entity is shutdown because the methods are never called Create a property to apply action when the entity is shutdown * fix: Cancel live entity when kord is cancel Add parent of coroutine in constructor of AbstractLiveKordEntity to automatically cancelled the live entity when kord is cancelled * fix: Resolve issue listening for onShutdown, chore: Refactor name shutdown Rename shutDown method to shudown to agree with the method shutdown in kord Resolve issue to listening event for onShutdown action with an empty action job * test: Add abstract class to tests live entity * test: Add tests for abstract live entity and general behavior * chore: Add generic type live entity in abstract class test * chore: Deprecate onCreate method never called by entity * test: Add tests for Member, Role and User live entity Add tests for LiveMember Add tests for LiveRole Add tests for LiveUser * feat: Support BanAddEvent in live guild * test: Change test classes to simulate event and manage it * chore: Remove annotation need token bot * chore: Adapt Role & User live test with send manual event * chore: Adapt Role & User live test with send manual event * test: Add check equality field of event, implements member live test * chore: Remove optIn no used * fix: Correction tests to send fake event instead of real interaction * test: Refactor test to build test with valid and random id * fix: Fix flow issue with delay .. * fix: Rename package to resolve gradle issue I don't know why * test: Add Atomic counter to test event * test: End tests for guild live entity * chore: Place deprecated annotation on live entity Place Deprecated annotation for create event * test: Live category test * chore: Use sequence random id from other tests * test: Tests for all live entities category * test: Add Integrations update for guild live entity * fix: Add delay between creation job and send event Apply a delay between creation jobs and send events to be sure that all jobs are ready to listen the events in flow Without that, this is possible that the test failed * chore: Add deprecated annotation on GuildCreateEvent for live channel * fix: Use guild test channel type (according to GuildMessageChannel) * chore: format * chore: change package name and function name * chore: Use randomID, refactor send event * chore: Doc about shutdown action * chore: Change ReplaceWith in Deprecated annotation, rename shutdown method to shutDown * fix: Remove shutdown action property Remove the onShutDownAction and shutdownAction property to exploit the function invokeOnCompletion from job. Change constructor of live entity to be able to set final the kord instance and launch event in the scope of the live entity * feat: Add cause of shut down live entity * chore: Set deprecate level to Error * test: Add test for LiveGuild with method onGuildCreate * chore: Rename method about completion of job * feat: Add cancellation exception class for live entity Add the class LiveCancellationException to be able to retrieve the event causing the completion of live entity * feat: Add cause of cancellation to retrieve event for each live entity Use the LiveCancellationException class in parameter of shutDown method to be able to retrieve the source event for each live entity * chore: format * tests: Remove delay and use queue to manage action Remove delay between event and replace by Queue to send event when the previous event is received * tests: Add tests for LiveCancellationException constructor Check if there is an error when the exception is called with or not reason message * chore: Refactor property of LiveCancellationException * fix: Null pointer in live entities tests Remove job property, remove delay to use kord.launch and invoke the first event only when the job is ready * chore: try to add delay in tests Add delay in test to help CI * chore: Create constante for delay time in tests * chore: try old system for tests with CI * fix: Remove non-existent code * Retry github action * tests: Check data event caused shutDown Check the data into the event causing the shutDown of the live entity * Retry github action * Retry github action * Retry github action * chore: Change sentence in deprecated annotation * chore: Remove replaceWith Remove replaceWith where the code cannot be correctly generated without instance of object * chore: Homogenize cancel message * chore: Fix imports and ReplaceWith for Deprecated annotation * chore: Remove ReplaceWith for forgotten Deprecated annotation * Fix duplicate update on live entitites (#298) * fix: Resolve issue about several call update function Use the default job children in live entity to call once times the update function * chore: Remove inline doc in test * fix: Use ShareFlow to manage update method * Retry github action * chore: format * Retry github action * feat: Add possibility to define Job parent to create live entities (#304) * feat: Add possibility to define Job parent to create live entities * fix: Use CoroutineScope to define parent * feat: Allows to set CoroutineScope for each method 'on' * feat: Set coroutineScope into constructor of Live entities Change the parameters of AbstractLiveKordEntity to use coroutineScope by delegation * Reload Github workflow * fix: Use kord.coroutineContext to build default CoroutineScope for live entities * Fix compilation issues * tests: Remove test file (#319) * inline supervisor job Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]> * 0.7.0: Update Readme/Changelog (#314) * clean up * update changelog: 0.7.0 * add dependencies * remove copy paste left-overs * Update maven central badge (#267) * improve readme and changelog * remove the dashes * use h2 for changes * Add #304 to the changelog * update changelog * api dump Co-authored-by: Michael Rittmeister <[email protected]> * Add components to webhook builders (#324) * Add components to webhook builders This adds component fields and DSLs to webhook message builders * Fix webhook builders allowed_mentions SerialName * update readme * api dump * clean rebuilt api files Co-authored-by: BartArys <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: SirNapkin1334 <[email protected]> Co-authored-by: qbosst <[email protected]> Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]>
* Ci tests improvement (#264) * allow running dokkaHtml on push * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * close InputStreams used for attachments (#309) * Ephemeral embed support (#296) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * Common builders for interaction response needs more work * Common builders for interaction response needs more work * Seal base builders for interaction response * make embeds list final * make allowedMentions additive * Fix tests * revert tests * Fix stream closed exception I still haven't managed to know the root of the problem but changing the append process fixed it... * use readBytes for Java 8 compatibility * Interaction create improvements (#294) * Expose the creation of application commands behavior * make message type sealed * Fix typo * document interaction create event * apply suggestions and add more details * replace the quotes * proper grammar, Hope * Improve slash command API and add support for components (#310) * Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * interaction code cleanup (#312) * clean up * clean up builders * remove content parameter * Apply suggestions * Make serialization of Snowflake consistent (#316) Snowflakes are decoded as Longs but encoded as Strings. Mixing these types is allowed in JSON (and is done by Discord quite frequently) but does lead to other encoding types failing. This commit changes snowflakes to be encoded and decoded as long values exclusively, and should fix the issue. * Add missing components (#318) * clean up * Add missing component builders * expose default permission * cosmetic changes * add missing overrides * remove actionRow from public interaction response builder * Apply formatting suggestion Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Guild nsfw level (#320) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * add NsfwLevel * update docs [ci skip] * clean up * Fix documentation Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Add non-builder editMessage overload (#323) * Fix followups method signiture (#321) * Fix followups * rename followup functions * Improve live entity life cycle (#315) * fix: Resolve issue about the onShutDown function for Live entities Add deprecated annotation on previous onShutDown extension method Add onShutDown value in LiveEntity to apply action in event or manual case of shutdown * feat: Use coroutine dispatcher for lifecycle of live entity classes Manage the interception of events with the lifecycle of the Live entity. * feat: Use default dispatcher in constructor of live entity * chore: Remove deprecated annotation on onShutDown methods * use and extract SupervisorJob where possible * allow handling a live entity completion * Add structured concurrency to live entity (#285) * test: Begin test for LiveMessage * test: Add tests for LiveMessage class Add tests for listen events Ignore tests where the lifecycle is break by event * chore: Remove useless imports * fix: shutdown action for live entity Deprecate the listening where the live entity is shutdown because the methods are never called Create a property to apply action when the entity is shutdown * fix: Cancel live entity when kord is cancel Add parent of coroutine in constructor of AbstractLiveKordEntity to automatically cancelled the live entity when kord is cancelled * fix: Resolve issue listening for onShutdown, chore: Refactor name shutdown Rename shutDown method to shudown to agree with the method shutdown in kord Resolve issue to listening event for onShutdown action with an empty action job * test: Add abstract class to tests live entity * test: Add tests for abstract live entity and general behavior * chore: Add generic type live entity in abstract class test * chore: Deprecate onCreate method never called by entity * test: Add tests for Member, Role and User live entity Add tests for LiveMember Add tests for LiveRole Add tests for LiveUser * feat: Support BanAddEvent in live guild * test: Change test classes to simulate event and manage it * chore: Remove annotation need token bot * chore: Adapt Role & User live test with send manual event * chore: Adapt Role & User live test with send manual event * test: Add check equality field of event, implements member live test * chore: Remove optIn no used * fix: Correction tests to send fake event instead of real interaction * test: Refactor test to build test with valid and random id * fix: Fix flow issue with delay .. * fix: Rename package to resolve gradle issue I don't know why * test: Add Atomic counter to test event * test: End tests for guild live entity * chore: Place deprecated annotation on live entity Place Deprecated annotation for create event * test: Live category test * chore: Use sequence random id from other tests * test: Tests for all live entities category * test: Add Integrations update for guild live entity * fix: Add delay between creation job and send event Apply a delay between creation jobs and send events to be sure that all jobs are ready to listen the events in flow Without that, this is possible that the test failed * chore: Add deprecated annotation on GuildCreateEvent for live channel * fix: Use guild test channel type (according to GuildMessageChannel) * chore: format * chore: change package name and function name * chore: Use randomID, refactor send event * chore: Doc about shutdown action * chore: Change ReplaceWith in Deprecated annotation, rename shutdown method to shutDown * fix: Remove shutdown action property Remove the onShutDownAction and shutdownAction property to exploit the function invokeOnCompletion from job. Change constructor of live entity to be able to set final the kord instance and launch event in the scope of the live entity * feat: Add cause of shut down live entity * chore: Set deprecate level to Error * test: Add test for LiveGuild with method onGuildCreate * chore: Rename method about completion of job * feat: Add cancellation exception class for live entity Add the class LiveCancellationException to be able to retrieve the event causing the completion of live entity * feat: Add cause of cancellation to retrieve event for each live entity Use the LiveCancellationException class in parameter of shutDown method to be able to retrieve the source event for each live entity * chore: format * tests: Remove delay and use queue to manage action Remove delay between event and replace by Queue to send event when the previous event is received * tests: Add tests for LiveCancellationException constructor Check if there is an error when the exception is called with or not reason message * chore: Refactor property of LiveCancellationException * fix: Null pointer in live entities tests Remove job property, remove delay to use kord.launch and invoke the first event only when the job is ready * chore: try to add delay in tests Add delay in test to help CI * chore: Create constante for delay time in tests * chore: try old system for tests with CI * fix: Remove non-existent code * Retry github action * tests: Check data event caused shutDown Check the data into the event causing the shutDown of the live entity * Retry github action * Retry github action * Retry github action * chore: Change sentence in deprecated annotation * chore: Remove replaceWith Remove replaceWith where the code cannot be correctly generated without instance of object * chore: Homogenize cancel message * chore: Fix imports and ReplaceWith for Deprecated annotation * chore: Remove ReplaceWith for forgotten Deprecated annotation * Fix duplicate update on live entitites (#298) * fix: Resolve issue about several call update function Use the default job children in live entity to call once times the update function * chore: Remove inline doc in test * fix: Use ShareFlow to manage update method * Retry github action * chore: format * Retry github action * feat: Add possibility to define Job parent to create live entities (#304) * feat: Add possibility to define Job parent to create live entities * fix: Use CoroutineScope to define parent * feat: Allows to set CoroutineScope for each method 'on' * feat: Set coroutineScope into constructor of Live entities Change the parameters of AbstractLiveKordEntity to use coroutineScope by delegation * Reload Github workflow * fix: Use kord.coroutineContext to build default CoroutineScope for live entities * Fix compilation issues * tests: Remove test file (#319) * inline supervisor job Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]> * 0.7.0: Update Readme/Changelog (#314) * clean up * update changelog: 0.7.0 * add dependencies * remove copy paste left-overs * Update maven central badge (#267) * improve readme and changelog * remove the dashes * use h2 for changes * Add #304 to the changelog * update changelog * api dump Co-authored-by: Michael Rittmeister <[email protected]> * Add components to webhook builders (#324) * Add components to webhook builders This adds component fields and DSLs to webhook message builders * Fix webhook builders allowed_mentions SerialName * update readme * api dump * clean rebuilt api files * Allow properties in message edits to be empty/null (#327) * Allow properties in message edits to be empty/null This gives properties in message edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. This is how it should have been from the start, but was missed in code review. * Update CHANGELOG.md * api dump * Fixes/fix followup nullability (#330) * Allow properties in message edits to be empty/null This gives properties in message edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. This is how it should have been from the start, but was missed in code review. * Fix followup nullability This gives properties in follow up edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. It also removes tts from the common interfaces, since only message creates can tts. * Update CHANGELOG.md * Fix components in interactions (#331) * Store components in ComponentData * Correctly retrieve the invoked component from an interaction * Update CHANGELOG.md * api dump Co-authored-by: BartArys <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: SirNapkin1334 <[email protected]> Co-authored-by: qbosst <[email protected]> Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]>
* Ci tests improvement (#264) * allow running dokkaHtml on push * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * close InputStreams used for attachments (#309) * Ephemeral embed support (#296) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * Common builders for interaction response needs more work * Common builders for interaction response needs more work * Seal base builders for interaction response * make embeds list final * make allowedMentions additive * Fix tests * revert tests * Fix stream closed exception I still haven't managed to know the root of the problem but changing the append process fixed it... * use readBytes for Java 8 compatibility * Interaction create improvements (#294) * Expose the creation of application commands behavior * make message type sealed * Fix typo * document interaction create event * apply suggestions and add more details * replace the quotes * proper grammar, Hope * Improve slash command API and add support for components (#310) * Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * interaction code cleanup (#312) * clean up * clean up builders * remove content parameter * Apply suggestions * Make serialization of Snowflake consistent (#316) Snowflakes are decoded as Longs but encoded as Strings. Mixing these types is allowed in JSON (and is done by Discord quite frequently) but does lead to other encoding types failing. This commit changes snowflakes to be encoded and decoded as long values exclusively, and should fix the issue. * Add missing components (#318) * clean up * Add missing component builders * expose default permission * cosmetic changes * add missing overrides * remove actionRow from public interaction response builder * Apply formatting suggestion Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Guild nsfw level (#320) * Fix return type of channel in VoiceState * support embeds in ephemeral messages * supply modify request with embeds * add NsfwLevel * update docs [ci skip] * clean up * Fix documentation Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Add non-builder editMessage overload (#323) * Fix followups method signiture (#321) * Fix followups * rename followup functions * Improve live entity life cycle (#315) * fix: Resolve issue about the onShutDown function for Live entities Add deprecated annotation on previous onShutDown extension method Add onShutDown value in LiveEntity to apply action in event or manual case of shutdown * feat: Use coroutine dispatcher for lifecycle of live entity classes Manage the interception of events with the lifecycle of the Live entity. * feat: Use default dispatcher in constructor of live entity * chore: Remove deprecated annotation on onShutDown methods * use and extract SupervisorJob where possible * allow handling a live entity completion * Add structured concurrency to live entity (#285) * test: Begin test for LiveMessage * test: Add tests for LiveMessage class Add tests for listen events Ignore tests where the lifecycle is break by event * chore: Remove useless imports * fix: shutdown action for live entity Deprecate the listening where the live entity is shutdown because the methods are never called Create a property to apply action when the entity is shutdown * fix: Cancel live entity when kord is cancel Add parent of coroutine in constructor of AbstractLiveKordEntity to automatically cancelled the live entity when kord is cancelled * fix: Resolve issue listening for onShutdown, chore: Refactor name shutdown Rename shutDown method to shudown to agree with the method shutdown in kord Resolve issue to listening event for onShutdown action with an empty action job * test: Add abstract class to tests live entity * test: Add tests for abstract live entity and general behavior * chore: Add generic type live entity in abstract class test * chore: Deprecate onCreate method never called by entity * test: Add tests for Member, Role and User live entity Add tests for LiveMember Add tests for LiveRole Add tests for LiveUser * feat: Support BanAddEvent in live guild * test: Change test classes to simulate event and manage it * chore: Remove annotation need token bot * chore: Adapt Role & User live test with send manual event * chore: Adapt Role & User live test with send manual event * test: Add check equality field of event, implements member live test * chore: Remove optIn no used * fix: Correction tests to send fake event instead of real interaction * test: Refactor test to build test with valid and random id * fix: Fix flow issue with delay .. * fix: Rename package to resolve gradle issue I don't know why * test: Add Atomic counter to test event * test: End tests for guild live entity * chore: Place deprecated annotation on live entity Place Deprecated annotation for create event * test: Live category test * chore: Use sequence random id from other tests * test: Tests for all live entities category * test: Add Integrations update for guild live entity * fix: Add delay between creation job and send event Apply a delay between creation jobs and send events to be sure that all jobs are ready to listen the events in flow Without that, this is possible that the test failed * chore: Add deprecated annotation on GuildCreateEvent for live channel * fix: Use guild test channel type (according to GuildMessageChannel) * chore: format * chore: change package name and function name * chore: Use randomID, refactor send event * chore: Doc about shutdown action * chore: Change ReplaceWith in Deprecated annotation, rename shutdown method to shutDown * fix: Remove shutdown action property Remove the onShutDownAction and shutdownAction property to exploit the function invokeOnCompletion from job. Change constructor of live entity to be able to set final the kord instance and launch event in the scope of the live entity * feat: Add cause of shut down live entity * chore: Set deprecate level to Error * test: Add test for LiveGuild with method onGuildCreate * chore: Rename method about completion of job * feat: Add cancellation exception class for live entity Add the class LiveCancellationException to be able to retrieve the event causing the completion of live entity * feat: Add cause of cancellation to retrieve event for each live entity Use the LiveCancellationException class in parameter of shutDown method to be able to retrieve the source event for each live entity * chore: format * tests: Remove delay and use queue to manage action Remove delay between event and replace by Queue to send event when the previous event is received * tests: Add tests for LiveCancellationException constructor Check if there is an error when the exception is called with or not reason message * chore: Refactor property of LiveCancellationException * fix: Null pointer in live entities tests Remove job property, remove delay to use kord.launch and invoke the first event only when the job is ready * chore: try to add delay in tests Add delay in test to help CI * chore: Create constante for delay time in tests * chore: try old system for tests with CI * fix: Remove non-existent code * Retry github action * tests: Check data event caused shutDown Check the data into the event causing the shutDown of the live entity * Retry github action * Retry github action * Retry github action * chore: Change sentence in deprecated annotation * chore: Remove replaceWith Remove replaceWith where the code cannot be correctly generated without instance of object * chore: Homogenize cancel message * chore: Fix imports and ReplaceWith for Deprecated annotation * chore: Remove ReplaceWith for forgotten Deprecated annotation * Fix duplicate update on live entitites (#298) * fix: Resolve issue about several call update function Use the default job children in live entity to call once times the update function * chore: Remove inline doc in test * fix: Use ShareFlow to manage update method * Retry github action * chore: format * Retry github action * feat: Add possibility to define Job parent to create live entities (#304) * feat: Add possibility to define Job parent to create live entities * fix: Use CoroutineScope to define parent * feat: Allows to set CoroutineScope for each method 'on' * feat: Set coroutineScope into constructor of Live entities Change the parameters of AbstractLiveKordEntity to use coroutineScope by delegation * Reload Github workflow * fix: Use kord.coroutineContext to build default CoroutineScope for live entities * Fix compilation issues * tests: Remove test file (#319) * inline supervisor job Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]> * 0.7.0: Update Readme/Changelog (#314) * clean up * update changelog: 0.7.0 * add dependencies * remove copy paste left-overs * Update maven central badge (#267) * improve readme and changelog * remove the dashes * use h2 for changes * Add #304 to the changelog * update changelog * api dump Co-authored-by: Michael Rittmeister <[email protected]> * Add components to webhook builders (#324) * Add components to webhook builders This adds component fields and DSLs to webhook message builders * Fix webhook builders allowed_mentions SerialName * update readme * api dump * clean rebuilt api files * Allow properties in message edits to be empty/null (#327) * Allow properties in message edits to be empty/null This gives properties in message edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. This is how it should have been from the start, but was missed in code review. * Update CHANGELOG.md * api dump * Fixes/fix followup nullability (#330) * Allow properties in message edits to be empty/null This gives properties in message edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. This is how it should have been from the start, but was missed in code review. * Fix followup nullability This gives properties in follow up edit builders the ability to encode values as null or empty lists when applicable, allowing you to remove fields from a message. It also removes tts from the common interfaces, since only message creates can tts. * Update CHANGELOG.md * Fix components in interactions (#331) * Store components in ComponentData * Correctly retrieve the invoked component from an interaction * Update CHANGELOG.md * api dump * add mentionable support (#333) * allow creating mentionables * Fix incorrect parsing of mentionables * Update changelog * clarify fixes Co-authored-by: BartArys <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: SirNapkin1334 <[email protected]> Co-authored-by: qbosst <[email protected]> Co-authored-by: Distractic <[email protected]> Co-authored-by: Distractic <[email protected]>
* Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]>
* Make slash command creation eager createGuildApplicationCommands and createGlobalApplicationCommands should eagerly create new commands to be more in line with the rest of the API * Fix typo in InteractionBehavior ackowledgePublic -> acknowledgePublic * Don't compute supplier in InteractionBehavior It's a waste of resources, and might result in unexpected behavior for non-Kord suppliers. * Specify withStrategy for Interactions Return types are important! * Introduce type to command options Also add Mentionable. Seems like Discord consistently tells us what kind of option an object is via the type field, this allows us to more clearly represent the json data in the lower level APIs. I ended up deleting DiscordOptionValue and replacing it with a more fleshed out CommandArgument. * Add KordDsl to builders * Add allowedMentions builder functions * Add permission edits to guild commands * Make full member available for guild contexts * Support buttons/components (#303) * Add new API models and properties * Add new InteractionCallbackType * Add ability to send components * Update core entities * Update tests * Add @KordPreview annotations * Convert don't trust doc comments to normal comments * Fix compilation issue * Optimize interaction serializing * Add builder * Fix tests * Apply some requested changes * Hopefully fix formatting * Make builders enforce Discord restrictions * Improve builders again * Remove LinkButtonBuilder.style * Improve builders - Add components to more supported builders - Make required fields parameters - Make builders appending * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) * Message interaction (#283) * Expose the creation of application commands behavior * Add interaction message * Apply suggestions * reference the MessageInteraction in docs * Implement Strategizable for MessageInteraction * cache user from interaction message * Fix compilation errors * Fix withStrategy return type Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Implement Stage instances (#291) * Add low-level implementation of stage instances * Add helper functions * Add core entities and api representations * Expose creation of StageInstanceBehavior to unsafe - Revert outdated change * Final additions - Add StageInstanceBehavior.asStageInstance - Fix compiler issue - Add StageChannelBehavior.getStageInstance() * Add StageInstances to EntitySupplier.kt * Add StageInstances to EntitySupplier.kt * Fix typo * Apply requested changes * Fix return type of channel in VoiceState (#295) * Fix return type of channel in VoiceState * Fix GuildService#modifyVoiceState endpoint * Fix MessageInteraction#user id * Add missing session start limit field (#306) - Adds the max_concurrency field to the session start limit data class * Update to Kotlin 1.5 (#299) * Update to 1.5.0-RC * trigger on branch pushes * Port to Kotlin 1.5 (#268) * Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest fixup! Port dependencies to Kotlin 1.5 - Convert AbstractRateLimiter.AbstractRequestToken to a static rather than an inner class due to a compiler bug - Downgrade kx.ser-json to 1.0.0 to avoid a compiler bug - Bump other Kotlin dependencies to latest * Replace deprecated kotlin.time APIs * Replace more deprecated APIs & inline classes * Replace deprecated usage of time API in tests * Possibly fix test Co-authored-by: Hope <[email protected]> * Port to Kotlin 1.5 - Bump dependencies to 1.5 recommended versions - Remove inline classes in favor of value classes - Add required opt-ins - Migrate some more deprecated apis * Fix some gradle issues * Fix Gradle compilation issue * Remove documentationFileName as the new dokka version doesn't support it anymore and there is no replacement yet * Port kotlinx.serialization to 1.2.0 (#279) * Port kotlinx.serialization to 1.2.0 - Convert local classes to top level classes (See Kotlin/kotlinx.serialization#1472) - Improve handling of empty JSON bodies (See Kotlin/kotlinx.serialization#678) - Fix Failing Command test * Fix failing test * Properly decode null in gateway events (#286) * Properly decode null in gateway events * Update gateway/src/main/kotlin/Event.kt Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Bart Arys <[email protected]> * Update Kotlinx.serialization (#290) * Update Kotlin 1.5 branch to upstream (#292) * Implement voice stage channel (#239) * compute All * implement rest endpoints * JSON representation * implement core representation * handle stage channels * Apply suggestions Co-authored-by: BartArys <[email protected]> * Remove duplicated factory function Co-authored-by: BartArys <[email protected]> * add documentation * Document the requestToSpeak variable Co-authored-by: BartArys <[email protected]> * Fix CI triggers * Add "Competing" activity type (Fix #270) (#272) * Make Updatestatus activities not-null (#274) As per Discord's documentation: discord/discord-api-docs#2789 * Fix memory issues related to Permission combining (#277) * Do not octuple bitset size on copy the pure plus and minus function create a new array to work with, this incorrectly created an array of a size equal to the amount of bits that were allocated, instead the amount of longs. Thus, octupling the internal size. * Optimize Permission All The All Permission folded each DiscordBitSet of each value into eachother, resulting in n + 1 bitsets being created. This commit changes that to use the internal `add` which instead, which only mutates the single bitset created. * Add Stream permission It was missing * Add Permission All regression tests * Update deprecated message (#280) * Expose the creation of application commands behavior (#281) * Fix GuildUpdate core handling (#284) * Expose the creation of application commands behavior * Fix type of emitted event * Sealed message types (#282) * Expose the creation of application commands behavior * Make message types sealed * make Unknown a class * Add missing message types * make MessageTypeSerializer internal * Add buttons to Activity (#287) * Add buttons to Activity * Also pass buttons in constructor * Add missing fields to Guild (#288) * Add missing fields to Guild - Add welcome_screen - Add nsfw * Fix failing tests * Fix another failing tests * Add Message.applicationId (#289) Co-authored-by: Hope <[email protected]> Co-authored-by: BartArys <[email protected]> Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Fix broken CI (#293) * Migrate to kotlinx-datetime (#297) * Migrate API code to kotlinx-datetime * Update tests * Remove dead code * Replace iso serializing with kx.dt * Bump dependencies to Kotlin 1.5.10 (#305) * Bump dependencies to Kotlin 1.5.10 - Fix sample code * Update remaining dependencies * Update ktor to 1.6.0 Co-authored-by: HopeBaron <[email protected]> Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> * Filter out non-guilds when fetching rest guilds (#301) This is a side-effect from the system we currently employ when it comes to creating channels. Unknown channels are instantiated as an anonymous channel without hierarchy. While we could assume it is a guild channel, it's not in actuality. So the solution, as we did with cache, is to filter out channels that don't inherit the hierarchy. * Improve builders again - Merge in upstream * Fix builder requirements - Fix error when sending a emoji button * Fix merge related syntax errors * Restore default sample * Fix formatting isssue in documentation Co-authored-by: Bart Arys <[email protected]> * Max component list a val Co-authored-by: Bart Arys <[email protected]> * Apply suggestions from code review Co-authored-by: Bart Arys <[email protected]> * Apply requested changes * No longer make DiscordInteraction a sealed class * Fix DiscordInteraction serialization * Add some documentation for components * Remove unused imports from builder Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: Bart Arys <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]> * Add core versions of components * Restructure and document ButtonBuilder * Remove ActionRowContainerBuilder * Make ComponentInteraction message nullable ephemeral messages in the interaction contain a id, which is not a message id, and the flags. We can't construct a behaviour from this (since the id isn't real), so I decided to drop the data if the message is ephemeral. * Add missing components to interaction builders * Add missing ComponentInteraction behavior * Fix withStrategy for ComponentInteractionBehavior * Implement ComponentInteractionBehavior * Move component builders directory We use singular for package names * Fix interaction embeds optionality * Make CommandInteraction#guildId optional * Make MessageModifyBuilder components vals Co-authored-by: Michael Rittmeister <[email protected]> Co-authored-by: Noah Hendrickson <[email protected]> Co-authored-by: Hope <[email protected]> Co-authored-by: 2D <[email protected]> Co-authored-by: HopeBaron <[email protected]>
I have a question related to this. I have an endpoint that returns either If we have the empty as null, then I can just decode it as |
@sandwwraith Thanks for the direction, I was manually setup a Customer Serializer to do it, but this seems indeed the functionality I am looking for to map an empty JSON as in empty str to an empty list. |
What is your use-case and why do you need this feature?
Unfortunately, not every API sends valid JSON. Sometimes, it sends an empty string instead null. To use the nullable type, I use a workaround based on the private serialized string and typed getter/setter. A custom serializer for classes, containing many members, is more complex than this workaround.
It would be nice, if the serialization framework could handle this workaround, as a custom setting.
JsonConfiguration(handleEmptyStringAsNull = true
The default value should be false, to enforce strict mode.
Describe the solution you'd like
The text was updated successfully, but these errors were encountered: