From 146768ea103f4590fdd772572b9b3527d852b0c3 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 22 Aug 2020 01:30:38 +0800 Subject: [PATCH] Fix exception message in PermissionDeniedException --- .../net/mamoe/mirai/qqandroid/contact/MemberImpl.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt index 53e7c17b7..ea8726168 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt @@ -180,7 +180,7 @@ internal class MemberImpl constructor( check(this.id != bot.id) { "A bot can't mute itself." } - checkBotPermissionHigherThanThis() + checkBotPermissionHigherThanThis("mute") bot.network.run { TroopManagement.Mute( client = bot.client, @@ -194,10 +194,10 @@ internal class MemberImpl constructor( net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast() } - private fun checkBotPermissionHigherThanThis() { + private fun checkBotPermissionHigherThanThis(operationName: String) { check(group.botPermission > this.permission) { throw PermissionDeniedException( - "`kick` operation requires bot to have a higher permission than the target member, " + + "`$operationName` operation requires bot to have a higher permission than the target member, " + "but bot's is ${group.botPermission}, target's is ${this.permission}" ) } @@ -205,7 +205,7 @@ internal class MemberImpl constructor( @JvmSynthetic override suspend fun unmute() { - checkBotPermissionHigherThanThis() + checkBotPermissionHigherThanThis("unmute") bot.network.run { TroopManagement.Mute( client = bot.client, @@ -222,7 +222,7 @@ internal class MemberImpl constructor( @JvmSynthetic override suspend fun kick(message: String) { - checkBotPermissionHigherThanThis() + checkBotPermissionHigherThanThis("kick") check(group.members.getOrNull(this.id) != null) { "Member ${this.id} had already been kicked from group ${group.id}" }