mirror of
https://github.com/Dummi26/mcdcbot.git
synced 2025-03-10 05:13:53 +01:00
add a way to run mc commands from discord
This commit is contained in:
parent
2fe29d15cc
commit
b5c31fd589
@ -127,6 +127,27 @@ async fn stop(ctx: Context<'_>) -> Result<(), Error> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
#[poise::command(slash_command)]
|
||||
async fn run_command(
|
||||
ctx: Context<'_>,
|
||||
#[description = "command (without '/')"] cmd: String,
|
||||
) -> Result<(), Error> {
|
||||
let current_lock = ctx.data().current.lock().await;
|
||||
if let Some((_, thread)) = current_lock.as_ref() {
|
||||
ctx.say(format!("Running '{cmd}'")).await?;
|
||||
_ = thread
|
||||
.lock()
|
||||
.await
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone_task_sender()
|
||||
.send_task(MinecraftServerTask::RunCommand(cmd));
|
||||
} else {
|
||||
ctx.say(format!("Use /start to start a server first"))
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn event_handler(
|
||||
ctx: &serenity::Context,
|
||||
|
Loading…
Reference in New Issue
Block a user