diff --git a/src/main/kotlin/main/events/AbstractEventController.kt b/src/main/kotlin/main/events/AbstractEventController.kt index d0195425..ea58ebb6 100644 --- a/src/main/kotlin/main/events/AbstractEventController.kt +++ b/src/main/kotlin/main/events/AbstractEventController.kt @@ -6,7 +6,7 @@ import main.main.Robertify import net.dv8tion.jda.api.events.GenericEvent import net.dv8tion.jda.api.hooks.ListenerAdapter -abstract class AbstractEventController : ListenerAdapter() { +abstract class AbstractEventController { companion object { protected val shardManager = Robertify.shardManager diff --git a/src/main/kotlin/main/main/Listener.kt b/src/main/kotlin/main/main/Listener.kt index 9cabd040..f501ec54 100644 --- a/src/main/kotlin/main/main/Listener.kt +++ b/src/main/kotlin/main/main/Listener.kt @@ -109,10 +109,6 @@ class Listener : AbstractEventController() { } } - override fun onGuildReady(event: GuildReadyEvent) { - logger.info("Guild ${event.guild.name} is ready") - } - private val guildJoinListener = onEvent { event -> val guild = event.guild diff --git a/src/main/kotlin/main/main/Robertify.kt b/src/main/kotlin/main/main/Robertify.kt index c27ca59e..faab165c 100644 --- a/src/main/kotlin/main/main/Robertify.kt +++ b/src/main/kotlin/main/main/Robertify.kt @@ -239,6 +239,7 @@ object Robertify { loadNeededSlashCommands(guild) rescheduleUnbans(guild) RemindersConfig(guild).scheduleReminders() + logger.info("${guild.name} is ready!") // GuildResumeManager(guild).loadTracks() } diff --git a/src/main/kotlin/main/utils/json/requestchannel/RequestChannelConfig.kt b/src/main/kotlin/main/utils/json/requestchannel/RequestChannelConfig.kt index 40b4821c..3a2a07d8 100644 --- a/src/main/kotlin/main/utils/json/requestchannel/RequestChannelConfig.kt +++ b/src/main/kotlin/main/utils/json/requestchannel/RequestChannelConfig.kt @@ -32,6 +32,7 @@ import net.dv8tion.jda.api.entities.MessageHistory import net.dv8tion.jda.api.entities.channel.concrete.TextChannel import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel import net.dv8tion.jda.api.exceptions.ErrorHandler +import net.dv8tion.jda.api.exceptions.ErrorResponseException import net.dv8tion.jda.api.exceptions.InsufficientPermissionException import net.dv8tion.jda.api.interactions.components.ActionRow import net.dv8tion.jda.api.interactions.components.buttons.Button @@ -181,7 +182,7 @@ class RequestChannelConfig(private val guild: Guild, private val shardManager: S suspend fun isChannelSet(): Boolean { val obj = getGuildModel().dedicated_channel - return obj != null && obj.channel_id != -1L + return obj.channel_id != -1L } suspend fun isRequestChannel(channel: GuildMessageChannel): Boolean = when { @@ -215,25 +216,14 @@ class RequestChannelConfig(private val guild: Guild, private val shardManager: S msg.editMessage(localeManager.getMessage(DedicatedChannelMessages.DEDICATED_CHANNEL_QUEUE_NOTHING_PLAYING)) .setEmbeds(eb.build()) .await() - // TODO: Handle unknown message error properly -// msgRequest.queue( -// { msg: Message -> -// -// }, -// ErrorHandler() -// .handle( -// ErrorResponse.UNKNOWN_MESSAGE -// ) { removeChannel() } -// .handle( -// ErrorResponse.MISSING_PERMISSIONS -// ) { -// sendEditErrorMessage( -// announcementChannel -// ) -// } -// ) } catch (e: InsufficientPermissionException) { if (e.message!!.contains("MESSAGE_SEND")) sendEditErrorMessage(announcementChannel) + } catch (e: ErrorResponseException) { + when (e.errorResponse) { + ErrorResponse.MISSING_PERMISSIONS -> sendEditErrorMessage(announcementChannel) + ErrorResponse.UNKNOWN_MESSAGE -> removeChannel() + else -> {} + } } } else { eb.setColor(theme.color)