Skip to content

Commit

Permalink
Finished migrating rest api and made all impls internal
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Mar 7, 2024
1 parent 6f94c59 commit be4356d
Show file tree
Hide file tree
Showing 108 changed files with 581 additions and 591 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/io/github/ydwk/yde/EntityInstanceBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ interface EntityInstanceBuilder {
* @param json the json
* @return [GuildScheduledEvent] the guild scheduled event
*/
fun buildGuildScheduledEvent(json: JsonNode): GuildScheduledEvent
suspend fun buildGuildScheduledEvent(json: JsonNode): GuildScheduledEvent

/**
* Used to build an instance of [Invite]
*
* @param json the json
* @return [Invite] the invite
*/
fun buildInvite(json: JsonNode): Invite
suspend fun buildInvite(json: JsonNode): Invite

/**
* Used to build an instance of [Member]
Expand Down
21 changes: 10 additions & 11 deletions src/main/kotlin/io/github/ydwk/yde/YDE.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ import io.github.ydwk.yde.entities.channel.getter.guild.GuildChannelGetter
import io.github.ydwk.yde.entities.guild.Member
import io.github.ydwk.yde.entities.message.embed.builder.EmbedBuilder
import io.github.ydwk.yde.rest.RestApiManager
import io.github.ydwk.yde.rest.RestResult
import io.github.ydwk.yde.rest.methods.RestAPIMethodGetters
import io.github.ydwk.yde.rest.type.RestResult
import io.github.ydwk.yde.util.Incubating
import io.github.ydwk.yde.util.ThreadFactory
import java.time.Duration
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineDispatcher
import org.jetbrains.annotations.BlockingExecutor

Expand Down Expand Up @@ -194,7 +193,7 @@ interface YDE {
* @param id The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuild(guildId: Long): CompletableDeferred<Guild> =
suspend fun requestGuild(guildId: Long): RestResult<Guild> =
restAPIMethodGetters.getGuildRestAPIMethods().requestedGuild(guildId)

/**
Expand All @@ -203,14 +202,14 @@ interface YDE {
* @param id The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuild(guildId: String): CompletableDeferred<Guild> = requestGuild(guildId.toLong())
suspend fun requestGuild(guildId: String): RestResult<Guild> = requestGuild(guildId.toLong())

/**
* Requests all the guilds the bot is in.
*
* @return The [RestResult] object.
*/
fun requestGuilds(): CompletableDeferred<List<Guild>> =
suspend fun requestGuilds(): RestResult<List<Guild>> =
restAPIMethodGetters.getGuildRestAPIMethods().requestedGuilds()

/**
Expand Down Expand Up @@ -308,7 +307,7 @@ interface YDE {
* @param id The id of the channel.
* @return The [RestResult] object.
*/
fun requestChannelById(id: Long): CompletableDeferred<Channel> =
suspend fun requestChannelById(id: Long): RestResult<Channel> =
restAPIMethodGetters.getChannelRestAPIMethods().requestChannel(id)

/**
Expand All @@ -317,7 +316,7 @@ interface YDE {
* @param id The id of the channel.
* @return The [RestResult] object.
*/
fun requestChannelById(id: String): CompletableDeferred<Channel> =
suspend fun requestChannelById(id: String): RestResult<Channel> =
requestChannelById(id.toLong())

/**
Expand All @@ -327,7 +326,7 @@ interface YDE {
* @param guildId The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuildChannelById(id: Long, guildId: Long): CompletableDeferred<GuildChannel> =
suspend fun requestGuildChannelById(id: Long, guildId: Long): RestResult<GuildChannel> =
restAPIMethodGetters.getChannelRestAPIMethods().requestGuildChannel(id, guildId)

/**
Expand All @@ -337,7 +336,7 @@ interface YDE {
* @param guildId The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuildChannelById(id: String, guildId: String): CompletableDeferred<GuildChannel> =
suspend fun requestGuildChannelById(id: String, guildId: String): RestResult<GuildChannel> =
requestGuildChannelById(id.toLong(), guildId.toLong())

/**
Expand All @@ -346,7 +345,7 @@ interface YDE {
* @param guildId The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuildChannels(guildId: Long): CompletableDeferred<List<GuildChannel>> =
suspend fun requestGuildChannels(guildId: Long): RestResult<List<GuildChannel>> =
restAPIMethodGetters.getChannelRestAPIMethods().requestGuildChannels(guildId)

/**
Expand All @@ -355,7 +354,7 @@ interface YDE {
* @param guildId The id of the guild.
* @return The [RestResult] object.
*/
fun requestGuildChannels(guildId: String): CompletableDeferred<List<GuildChannel>> =
suspend fun requestGuildChannels(guildId: String): RestResult<List<GuildChannel>> =
requestGuildChannels(guildId.toLong())

/** Sets the guild ids for guild commands */
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/ydwk/yde/cache/Cache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ interface Cache {
* @param duration The duration to wait before clearing the cache
* @param repeat whether to repeat the clearing of the cache
*/
fun triggerCacheTypesClear(cacheIds: List<CacheIds>, duration: Duration, repeat: Boolean = true)
fun triggerCacheTypesClear(cacheIds: Set<CacheIds>, duration: Duration, repeat: Boolean = true)

/**
* Triggers a thread to clear the entire cache after a certain amount of time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ open class ConcurrentCache(private val allowedCache: Set<CacheIds>, private val
}

override fun triggerCacheTypesClear(
cacheIds: List<CacheIds>,
cacheIds: Set<CacheIds>,
duration: Duration,
repeat: Boolean
) {
Expand Down
Loading

0 comments on commit be4356d

Please sign in to comment.