Skip to content
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

Slash commands #145

Merged
merged 41 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
aaeba3a
Add interaction models
Dec 17, 2020
eb55b44
Add interaction routes
Dec 17, 2020
0bf6285
Add interactions rest service
Dec 17, 2020
74e69c1
Move AllowedMentions to common
Dec 17, 2020
965f566
Add serialization strategy for interaction type
Dec 17, 2020
8c89b6c
Add interaction create event
Dec 18, 2020
2f1b2ea
Add interactions to RestClient
Dec 18, 2020
7cc469e
Add interactions requests and builders
Dec 18, 2020
df3ad16
Fix errors due to rename
Dec 18, 2020
9f5f282
introduce a KordEntity type
Dec 19, 2020
290b16d
Fix incorrect type representation
Dec 19, 2020
31ad6f9
Add slash commands core representation
Dec 19, 2020
7a1c1d7
Add missing interaction requests and fix route returns
Dec 19, 2020
5b5011e
remove redundant applicationId
Dec 19, 2020
d26057c
Move application command data to matching file name
Dec 19, 2020
9125b0a
Fix undocumented api behaviors
Dec 20, 2020
a401fea
Add missing applicationId and remove redundant properties
Dec 22, 2020
4520909
Fix rest endpoints and builders
Dec 22, 2020
5c841d9
Add interactions core entities and behaviors
Dec 22, 2020
8b37445
Remove pongs from interactions
Dec 22, 2020
6e2d930
Add wrapping class for parameters
Dec 23, 2020
d588baf
Allow no-parameter commands in builders
Dec 23, 2020
1d243ef
Add application command gateway events
Dec 24, 2020
ba566fa
Add convenient builders and @KordPreview for slash commands
Dec 25, 2020
d85db9c
[WIP] - Options core representation
Jan 1, 2021
3bd7761
Simplyify filterInstanceOfList
BartArys Jan 2, 2021
aa98542
WIP: deserialize incoming interactions
BartArys Jan 2, 2021
9a59b62
WIP - Add core representation for Groups, Commands, and Subcommands
Jan 2, 2021
125e4c0
Document those interactions :tada:
Jan 2, 2021
fbdfa3c
Assume the interaction's parameters are major
Jan 3, 2021
d5418db
Document NotSerializable serializer
Jan 3, 2021
2297467
Restore CacheMissRegression
Jan 3, 2021
d124f40
Apply contracts and add docs to SlashCommands
Jan 3, 2021
b8f0778
Add a convenient method to transform value into Snowflake
Jan 3, 2021
c15942c
Replace ExperimentalContracts with OptIn
Jan 3, 2021
c69e7d2
Improve docs
Jan 3, 2021
cd3ae82
Fix more typos
Jan 3, 2021
fe4c737
Document properties of Command and it's children
Jan 3, 2021
f916630
Add permissions to the interaction
HopeBaron Jan 4, 2021
46d246a
Include a SlashCommands reference inside Kord and Guilds
HopeBaron Jan 4, 2021
326f18b
Merge branch '0.7.x' into slash-commands
HopeBaron Jan 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions common/src/main/kotlin/entity/DiscordMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,35 @@ enum class MessageType(val code: Int) {
}
}
}
@Serializable(with = AllowedMentionType.Serializer::class)
sealed class AllowedMentionType(val value: String) {
class Unknown(value: String) : AllowedMentionType(value)
object RoleMentions : AllowedMentionType("roles")
object UserMentions : AllowedMentionType("users")
object EveryoneMentions : AllowedMentionType("everyone")

internal class Serializer : KSerializer<AllowedMentionType> {
override val descriptor: SerialDescriptor
get() = PrimitiveSerialDescriptor("Kord.DiscordAllowedMentionType", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): AllowedMentionType = when(val value = decoder.decodeString()) {
"roles" -> RoleMentions
"users" -> UserMentions
"everyone" -> EveryoneMentions
else -> Unknown(value)
}

override fun serialize(encoder: Encoder, value: AllowedMentionType) {
encoder.encodeString(value.value)
}
}
}

@Serializable
data class AllowedMentions(
val parse: List<AllowedMentionType>,
val users: List<String>,
val roles: List<String>,
@SerialName("replied_user")
val repliedUser: OptionalBoolean = OptionalBoolean.Missing
)
Loading