You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
use crate::commands::common::handle_autodelete;
|
|
|
|
use serenity::framework::standard::macros::command;
|
|
|
|
use serenity::framework::standard::{Args, CommandResult};
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
use serenity::prelude::*;
|
|
|
|
use std::process;
|
|
|
|
|
|
|
|
#[command]
|
|
|
|
#[description("Shuts down the bot with the specified exit code")]
|
|
|
|
#[min_args(0)]
|
|
|
|
#[max_args(1)]
|
|
|
|
#[usage("(<code>)")]
|
|
|
|
#[owners_only]
|
|
|
|
async fn shutdown(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
|
|
|
let code = args.single::<i32>().unwrap_or(0);
|
|
|
|
log::info!("Shutting down with code {}...", code);
|
|
|
|
msg.channel_id
|
|
|
|
.say(
|
|
|
|
ctx,
|
|
|
|
format!(":night_with_stars: Good night (code: {})...", code),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
handle_autodelete(ctx, msg).await?;
|
|
|
|
process::exit(code);
|
|
|
|
}
|