ottobot-v3/src/main/kotlin/nl/voidcorp/ottobot/commands/roles/RemoveRoleCommand.kt

24 lines
805 B
Kotlin

package nl.voidcorp.ottobot.commands.roles
import nl.voidcorp.ottobot.command.*
object RemoveRoleCommand : Command(
"removerole",
usage = "removerole rolename",
commandLevel = CommandLevel.MODERATOR,
location = CommandSource.GUILD,
group = CommandGroup.ADMIN
) {
override fun handle(event: CommandMessage): CommandResult {
if (event.params.drop(1).isEmpty()) return CommandResult.PARAMETERS
val guild = getStore(event.guild!!.idLong)
val toRemove = guild.roleMap.keys.intersect(event.params.drop(1))
toRemove.forEach { guild.roleMap.remove(it) }
event.reply("Removed ${toRemove.size} roles from the list. ")
event.reply(toRemove.joinToString(prefix = "(", postfix = ")") { "`$it`" })
return CommandResult.SUCCESS
}
}