mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
Merge pull request #88 from dalbodeule/develop
apiDiscordRoutes fix. (7x)
This commit is contained in:
commit
380e36188f
@ -22,19 +22,20 @@ object DiscordGuildCache {
|
|||||||
|
|
||||||
suspend fun getCachedGuilds(guildId: String): Guild? {
|
suspend fun getCachedGuilds(guildId: String): Guild? {
|
||||||
val now = Instant.now()
|
val now = Instant.now()
|
||||||
val guild = cache[guildId]
|
var guild = cache[guildId]
|
||||||
|
|
||||||
if(guild == null || guild.timestamp.plusSeconds(EXP_SECONDS).isBefore(now) || !guild.isBotAvailable) {
|
if(guild == null || guild.timestamp.plusSeconds(EXP_SECONDS).isBefore(now) || !guild.isBotAvailable) {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
if(guild == null || guild.timestamp.plusSeconds(EXP_SECONDS).isBefore(now) || !guild.isBotAvailable) {
|
if(guild == null || guild!!.timestamp.plusSeconds(EXP_SECONDS).isBefore(now) || !guild!!.isBotAvailable) {
|
||||||
fetchAllGuilds()
|
fetchAllGuilds()
|
||||||
|
guild = cache[guildId]
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (guild?.guild?.roles?.isEmpty() == true) {
|
if (guild!!.guild.roles.isEmpty()) {
|
||||||
guild.guild.roles = fetchGuildRoles(guildId)
|
guild!!.guild.roles = fetchGuildRoles(guildId)
|
||||||
}
|
}
|
||||||
if (guild?.guild?.channel?.isEmpty() == true) {
|
if (guild!!.guild.channel.isEmpty()) {
|
||||||
guild.guild.channel = fetchGuildChannels(guildId)
|
guild!!.guild.channel = fetchGuildChannels(guildId)
|
||||||
}
|
}
|
||||||
} catch(e: Exception) {
|
} catch(e: Exception) {
|
||||||
logger.info("guild fetch is failed.")
|
logger.info("guild fetch is failed.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user