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

Top channels #353

Merged
merged 12 commits into from
Aug 2, 2021
Merged

Top channels #353

merged 12 commits into from
Aug 2, 2021

Conversation

HopeBaron
Copy link
Member

  • Renames our known channel types (Interfaces only) into TopXGuildChannel Where X is a guild channel variant.
  • Reuse GuildChannel and GuildMessageChannel to include shared behaviors / data between threads and top level channels.
  • Rename ThreadUser to ThreadMember for consistency and maybe future changes for discord
  • Add missing behaviors / data for thread-related entities.

Comment on lines 101 to 123
fun TopGuildChannelBehavior(
guildId: Snowflake,
id: Snowflake,
kord: Kord,
strategy: EntitySupplyStrategy<*> = kord.resources.defaultStrategy
): TopGuildChannelBehavior = object : TopGuildChannelBehavior {
override val guildId: Snowflake = guildId
override val id: Snowflake = id
override val kord: Kord = kord
override val supplier: EntitySupplier = strategy.supply(kord)

override fun hashCode(): Int = Objects.hash(id, guildId)

override fun equals(other: Any?): Boolean = when (other) {
is GuildChannelBehavior -> other.id == id && other.guildId == guildId
is ChannelBehavior -> other.id == id
else -> false
}

override fun toString(): String {
return "TopGuildChannelBehavior(id=$id, guildId=$guildId, kord=$kord, supplier=$supplier)"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be internal

Comment on lines 38 to 42
fun guildChannel(guildId: Snowflake, id: Snowflake): GuildChannelBehavior =
GuildChannelBehavior(guildId = guildId, id = id, kord = kord)
fun guildChannel(guildId: Snowflake, id: Snowflake): TopGuildChannelBehavior =
TopGuildChannelBehavior(guildId = guildId, id = id, kord = kord)

fun guildMessageChannel(guildId: Snowflake, id: Snowflake): GuildMessageChannelBehavior =
GuildMessageChannelBehavior(guildId = guildId, id = id, kord = kord)
fun guildMessageChannel(guildId: Snowflake, id: Snowflake): TopGuildMessageChannelBehavior =
TopGuildMessageChannelBehavior(guildId = guildId, id = id, kord = kord)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For correctness, I think these should include top in their name.

Comment on lines 107 to 113
override fun hashCode(): Int = Objects.hash(id, guildId)

override fun equals(other: Any?): Boolean = when (other) {
is GuildChannelBehavior -> other.id == id && other.guildId == guildId
is ChannelBehavior -> other.id == id
else -> false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Comment on lines 26 to 29
/**
* The behavior of a Discord channel associated to a [guild].
*/
interface TopGuildChannelBehavior : GuildChannelBehavior {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should explain what constitutes as a top channel, and how it is different from a not-top channel

@HopeBaron HopeBaron merged commit cb9871f into 0.8.x Aug 2, 2021
@HopeBaron HopeBaron deleted the top-channels branch October 7, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants