From 732c043398a5142f42065f45aa43b71cba6f2972 Mon Sep 17 00:00:00 2001 From: Romira915 <40430090+Romira915@users.noreply.github.com> Date: Wed, 19 Apr 2023 08:59:54 +0000 Subject: [PATCH] fix: when stop non args, all stop --- discord_bot_client/src/commands/ark.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/discord_bot_client/src/commands/ark.rs b/discord_bot_client/src/commands/ark.rs index f5a0067..2e914b7 100644 --- a/discord_bot_client/src/commands/ark.rs +++ b/discord_bot_client/src/commands/ark.rs @@ -66,18 +66,21 @@ async fn status(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { #[command] #[description = "ARKサーバを停止する.args: int int int ... int"] async fn stop(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { + if args.is_empty() { + ArkFirst::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; + ArkSecond::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; + ArkThird::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; + ArkFourth::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; + + return Ok(()); + } + for arg in args.iter::() { match arg { Ok(1) => ArkFirst::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?, Ok(2) => ArkSecond::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?, Ok(3) => ArkThird::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?, Ok(4) => ArkFourth::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?, - Err(_) => { - ArkFirst::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; - ArkSecond::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; - ArkThird::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; - ArkFourth::ark_command_exec(SystemctlCommand::Stop, ctx, msg).await?; - } _ => (), } }