From 04483f345a823816c2109ae66e33d4bd9abf0ae3 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 3 Dec 2024 10:33:13 +0100 Subject: [PATCH] Fix permission troubleshooter --- .../space/votebot/util/PermissionUtil.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt b/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt index 0cb89a9..c652407 100644 --- a/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt +++ b/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt @@ -27,13 +27,23 @@ private val requiredPermissions = suspend fun SlashCommandContext<*, A, *>.checkPermissions(channel: GuildMessageChannel): Boolean { val selfPermissions = channel.getEffectivePermissions(channel.kord.selfId) if (requiredPermissions !in selfPermissions) { - sendMissingPermissions(VoteBotTranslations.Vote.Create.MissingPermissions.bot, channel, channel.kord.selfId, selfPermissions) + sendMissingPermissions( + VoteBotTranslations.Vote.Create.MissingPermissions.bot, + channel, + channel.kord.selfId, + selfPermissions + ) return false } val userPermissions = channel.getEffectivePermissions(user.id) if ((requiredPermissions - Permission.ViewChannel) !in userPermissions) { - sendMissingPermissions(VoteBotTranslations.Vote.Create.MissingPermissions.user, channel, user.id, userPermissions) + sendMissingPermissions( + VoteBotTranslations.Vote.Create.MissingPermissions.user, + channel, + user.id, + userPermissions + ) return false } @@ -64,11 +74,9 @@ private suspend fun SlashCommandContext<*, *, *>.sendMissingPermissions( val missingPermissions = (requiredPermissions - permissions).values.map { translate( VoteBotTranslations.Vote.Create.MissingPermissions.Explainer.permission, - arrayOf( - it.translate(this@sendMissingPermissions), - (it in serverPermissions).translate(), - (it in permissions).translate(), - ) + it.translate(this@sendMissingPermissions), + (it in serverPermissions).translate(), + (it in permissions).translate(), ) }.joinToString("\n")