feat: added CleanUpExtension
This commit is contained in:
parent
63e1d5b283
commit
39802598b2
1 changed files with 39 additions and 0 deletions
|
@ -0,0 +1,39 @@
|
|||
package net.moonleay.rssbot.extensions
|
||||
|
||||
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
|
||||
import com.kotlindiscord.kord.extensions.types.respond
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import net.moonleay.rssbot.Bot
|
||||
import net.moonleay.rssbot.data.database.repository.SubscriptionRepository
|
||||
import net.moonleay.rssbot.util.EmbedColor
|
||||
import net.moonleay.rssbot.util.MessageUtil
|
||||
|
||||
class CleanUpExtension : Extension() {
|
||||
|
||||
override val name = "cleanup"
|
||||
override val allowApplicationCommandInDMs: Boolean
|
||||
get() = false
|
||||
|
||||
|
||||
override suspend fun setup() {
|
||||
ephemeralSlashCommand() {
|
||||
name = "cleanup"
|
||||
description = "Clean all messages from this bot in this channel"
|
||||
this.action {
|
||||
val user = this.user.asUser()
|
||||
this.channel.messages.filter { it.author?.id == Bot.bot.kordRef.selfId }.collect { it.delete() }
|
||||
this.respond {
|
||||
this.embeds.add(
|
||||
MessageUtil.getEmbed(
|
||||
EmbedColor.INFO,
|
||||
"Cleaned up",
|
||||
"Cleaned up all messages from this bot in this channel",
|
||||
user.username
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue