This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more fields to the Member interface, add InteractionMember interf…
…ace, use our own custom Kord fork for now (#22) * Add more fields to the Member interface, add InteractionMember interface Does not compile because kordlib/kord#502 needs to be merged first * Use our own fork while Kord our changes aren't merged yet
- Loading branch information
1 parent
37e9e22
commit 6957ea0
Showing
14 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
object Versions { | ||
const val DISCORD_INTERAKTIONS = "0.0.12-SNAPSHOT" | ||
const val KOTLIN = "1.6.10" | ||
const val KORD = "0.8.x-SNAPSHOT" | ||
const val KORD = "0.8.x-lori-fork-SNAPSHOT" | ||
const val KTOR = "1.6.7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...rc/main/kotlin/net/perfectdreams/discordinteraktions/common/entities/InteractionMember.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.perfectdreams.discordinteraktions.common.entities | ||
|
||
import dev.kord.common.entity.Permissions | ||
import dev.kord.common.entity.Snowflake | ||
import kotlinx.datetime.Instant | ||
|
||
interface InteractionMember : Member { | ||
val permissions: Permissions | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/main/kotlin/net/perfectdreams/discordinteraktions/common/entities/Member.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package net.perfectdreams.discordinteraktions.common.entities | ||
|
||
import dev.kord.common.entity.Snowflake | ||
import kotlinx.datetime.Instant | ||
|
||
interface Member { | ||
val user: User | ||
val nick: String? | ||
val roles: List<Snowflake> | ||
val joinedAt: Instant | ||
val premiumSince: Instant? | ||
val pending: Boolean | ||
val avatar: UserAvatar? | ||
val communicationDisabledUntil: Instant? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../main/kotlin/net/perfectdreams/discordinteraktions/common/interactions/ResolvedObjects.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package net.perfectdreams.discordinteraktions.common.interactions | ||
|
||
import dev.kord.common.entity.Snowflake | ||
import net.perfectdreams.discordinteraktions.common.entities.Member | ||
import net.perfectdreams.discordinteraktions.common.entities.InteractionMember | ||
import net.perfectdreams.discordinteraktions.common.entities.User | ||
import net.perfectdreams.discordinteraktions.common.entities.messages.Message | ||
|
||
// TODO: channels | ||
// TODO: roles | ||
class ResolvedObjects( | ||
val users: Map<Snowflake, User>?, | ||
val members: Map<Snowflake, Member>?, | ||
val members: Map<Snowflake, InteractionMember>?, | ||
val messages: Map<Snowflake, Message>? | ||
) |
24 changes: 21 additions & 3 deletions
24
...in/net/perfectdreams/discordinteraktions/platforms/kord/entities/KordInteractionMember.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package net.perfectdreams.discordinteraktions.platforms.kord.entities | ||
|
||
import dev.kord.common.entity.DiscordInteractionGuildMember | ||
import net.perfectdreams.discordinteraktions.common.entities.Member | ||
import kotlinx.datetime.Instant | ||
import net.perfectdreams.discordinteraktions.common.entities.InteractionMember | ||
import net.perfectdreams.discordinteraktions.common.entities.User | ||
import net.perfectdreams.discordinteraktions.common.entities.UserAvatar | ||
|
||
// This is the same thing as KordMember, however an Interaction guild member does not have a deaf or mute flag | ||
class KordInteractionMember( | ||
val handle: DiscordInteractionGuildMember, | ||
override val user: User // The user object is here too because sometimes the handle user value may be null! | ||
) : Member { | ||
override val roles = handle.roles | ||
) : InteractionMember { | ||
override val nick: String? | ||
get() = handle.nick.value | ||
override val roles by handle::roles | ||
override val joinedAt = Instant.parse(handle.joinedAt) | ||
override val premiumSince = handle.premiumSince.value?.let { Instant.parse(it) } | ||
override val permissions by handle::permissions | ||
override val pending: Boolean | ||
get() = handle.pending.discordBoolean | ||
override val avatar = handle.avatar.value?.let { | ||
UserAvatar( | ||
user.id.value, | ||
user.discriminator.toInt(), | ||
it | ||
) | ||
} | ||
override val communicationDisabledUntil: Instant? | ||
get() = handle.communicationDisabledUntil.value | ||
} |
22 changes: 21 additions & 1 deletion
22
...c/main/kotlin/net/perfectdreams/discordinteraktions/platforms/kord/entities/KordMember.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
package net.perfectdreams.discordinteraktions.platforms.kord.entities | ||
|
||
import dev.kord.common.entity.DiscordGuildMember | ||
import dev.kord.common.entity.DiscordInteractionGuildMember | ||
import kotlinx.datetime.Instant | ||
import net.perfectdreams.discordinteraktions.common.entities.InteractionMember | ||
import net.perfectdreams.discordinteraktions.common.entities.Member | ||
import net.perfectdreams.discordinteraktions.common.entities.User | ||
import net.perfectdreams.discordinteraktions.common.entities.UserAvatar | ||
|
||
// This is the same thing as KordMember, however an Interaction guild member does not have a deaf or mute flag | ||
class KordMember( | ||
val handle: DiscordGuildMember, | ||
override val user: User // The user object is here too because sometimes the handle user value may be null! | ||
) : Member { | ||
override val roles = handle.roles | ||
override val nick: String? | ||
get() = handle.nick.value | ||
override val roles by handle::roles | ||
override val joinedAt = Instant.parse(handle.joinedAt) | ||
override val premiumSince = handle.premiumSince.value?.let { Instant.parse(it) } | ||
override val pending: Boolean | ||
get() = handle.pending.discordBoolean | ||
override val avatar = handle.avatar.value?.let { | ||
UserAvatar( | ||
user.id.value, | ||
user.discriminator.toInt(), | ||
it | ||
) | ||
} | ||
override val communicationDisabledUntil: Instant? | ||
get() = handle.communicationDisabledUntil.value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters