mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 06:10:30 +08:00
Fix exception message in PermissionDeniedException
This commit is contained in:
parent
e56e4ec1db
commit
146768ea10
@ -180,7 +180,7 @@ internal class MemberImpl constructor(
|
|||||||
check(this.id != bot.id) {
|
check(this.id != bot.id) {
|
||||||
"A bot can't mute itself."
|
"A bot can't mute itself."
|
||||||
}
|
}
|
||||||
checkBotPermissionHigherThanThis()
|
checkBotPermissionHigherThanThis("mute")
|
||||||
bot.network.run {
|
bot.network.run {
|
||||||
TroopManagement.Mute(
|
TroopManagement.Mute(
|
||||||
client = bot.client,
|
client = bot.client,
|
||||||
@ -194,10 +194,10 @@ internal class MemberImpl constructor(
|
|||||||
net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast()
|
net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkBotPermissionHigherThanThis() {
|
private fun checkBotPermissionHigherThanThis(operationName: String) {
|
||||||
check(group.botPermission > this.permission) {
|
check(group.botPermission > this.permission) {
|
||||||
throw PermissionDeniedException(
|
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}"
|
"but bot's is ${group.botPermission}, target's is ${this.permission}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ internal class MemberImpl constructor(
|
|||||||
|
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
override suspend fun unmute() {
|
override suspend fun unmute() {
|
||||||
checkBotPermissionHigherThanThis()
|
checkBotPermissionHigherThanThis("unmute")
|
||||||
bot.network.run {
|
bot.network.run {
|
||||||
TroopManagement.Mute(
|
TroopManagement.Mute(
|
||||||
client = bot.client,
|
client = bot.client,
|
||||||
@ -222,7 +222,7 @@ internal class MemberImpl constructor(
|
|||||||
|
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
override suspend fun kick(message: String) {
|
override suspend fun kick(message: String) {
|
||||||
checkBotPermissionHigherThanThis()
|
checkBotPermissionHigherThanThis("kick")
|
||||||
check(group.members.getOrNull(this.id) != null) {
|
check(group.members.getOrNull(this.id) != null) {
|
||||||
"Member ${this.id} had already been kicked from group ${group.id}"
|
"Member ${this.id} had already been kicked from group ${group.id}"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user