Skip to content

Commit 786bb0a

Browse files
committed
Exit command.
1 parent 44687bc commit 786bb0a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package dev.arbjerg.ukulele.command
2+
3+
import dev.arbjerg.ukulele.features.HelpContext
4+
import dev.arbjerg.ukulele.jda.Command
5+
import dev.arbjerg.ukulele.jda.CommandContext
6+
import dev.arbjerg.ukulele.config.BotProps
7+
import org.springframework.stereotype.Component
8+
import kotlin.system.exitProcess
9+
10+
@Component
11+
class ExitCommand(val botProps: BotProps) : Command("exit") {
12+
override suspend fun CommandContext.invoke() {
13+
if (message.author.id != botProps.ownerId) {
14+
reply("You do not have permission to run this command.")
15+
return
16+
}
17+
18+
reply("Shutting down...")
19+
// Give JDA a moment to send the reply
20+
Thread.sleep(1000)
21+
exitProcess(0)
22+
}
23+
24+
override fun HelpContext.provideHelp() {
25+
addUsage("")
26+
addDescription("Shuts down the bot gracefully (Owner only).")
27+
}
28+
}

0 commit comments

Comments
 (0)