mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-08 05:11:12 +00:00
add remove command
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package space.mori.chzzk_bot.services
|
||||
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import space.mori.chzzk_bot.models.Command
|
||||
import space.mori.chzzk_bot.models.Commands
|
||||
@@ -17,6 +18,17 @@ object CommandService {
|
||||
}
|
||||
}
|
||||
|
||||
fun removeCommand(user: User, command: String): Command? {
|
||||
return transaction {
|
||||
val commandRow = Command.find(Commands.user eq user.id and(Commands.command eq command)).firstOrNull()
|
||||
|
||||
commandRow ?: throw RuntimeException("Command not found! $command")
|
||||
commandRow.delete()
|
||||
|
||||
return@transaction commandRow
|
||||
}
|
||||
}
|
||||
|
||||
fun getCommand(id: Int): Command? {
|
||||
return transaction {
|
||||
return@transaction Command.findById(id)
|
||||
|
Reference in New Issue
Block a user