diff --git a/common/src/commonMain/kotlin/space/votebot/common/models/Poll.kt b/common/src/commonMain/kotlin/space/votebot/common/models/Poll.kt index 5be3747..d3f2757 100644 --- a/common/src/commonMain/kotlin/space/votebot/common/models/Poll.kt +++ b/common/src/commonMain/kotlin/space/votebot/common/models/Poll.kt @@ -72,6 +72,8 @@ public data class Poll( public data class ActualOption(override val position: Int?, val option: String, val emoji: Emoji?) : Option() { @Serializable public data class Emoji(val id: ULong?, val name: String?) + + override fun toString(): String = option } /** diff --git a/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt b/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt index 46c960d..6e79d52 100644 --- a/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt +++ b/plugin/src/main/kotlin/space/votebot/util/PermissionUtil.kt @@ -8,20 +8,18 @@ import dev.kord.common.entity.Snowflake import dev.kord.core.entity.channel.GuildMessageChannel import dev.kord.core.entity.channel.TopGuildMessageChannel import dev.kord.core.entity.channel.thread.ThreadChannel -import dev.kord.core.supplier.EntitySupplyStrategy import dev.schlaubi.mikbot.plugin.api.util.discordError suspend fun SlashCommandContext<*, A, *>.checkPermissions(channel: GuildMessageChannel) { - val restChannel = channel.withStrategy(EntitySupplyStrategy.rest) - val selfPermissions = restChannel.getEffectivePermissions(channel.kord.selfId) + val selfPermissions = channel.getEffectivePermissions(channel.kord.selfId) val requiredPermissions = Permissions(Permission.SendMessages, Permission.EmbedLinks, Permission.AttachFiles, Permission.ViewChannel) if (requiredPermissions !in selfPermissions) { discordError(translate("vote.create.missing_permissions.bot", arrayOf(channel.mention))) } - val userPermissions = restChannel.getEffectivePermissions(user.id) - if (requiredPermissions !in userPermissions) { + val userPermissions = channel.getEffectivePermissions(user.id) + if ((requiredPermissions - Permission.ViewChannel) !in userPermissions) { discordError(translate("vote.create.missing_permissions.user", arrayOf(channel.mention))) } }