Skip to content

Commit

Permalink
fix: when stop non args, all stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Romira915 committed Apr 19, 2023
1 parent 5245ce9 commit 732c043
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions discord_bot_client/src/commands/ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>() {
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?;
}
_ => (),
}
}
Expand Down

0 comments on commit 732c043

Please sign in to comment.