moved "debug" commands to a single command to reduce clutter
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
use crate::{messages::send_msg, Context, Error};
|
||||
|
||||
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
prefix_command,
|
||||
rename = "ping",
|
||||
category = "fun",
|
||||
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
|
||||
)]
|
||||
/// Check if you have connection to the bot.
|
||||
pub async fn cmd(
|
||||
ctx: Context<'_>,
|
||||
#[description = "The text to echo back."] text: Option<String>,
|
||||
) -> Result<(), Error>
|
||||
{
|
||||
send_msg(ctx, text.unwrap_or_else(|| "Pong".to_string()), true, true).await;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
use crate::{data::{self, get_toml_mutex, read_cfg_data}, lang, messages::send_msg, Context, Error};
|
||||
|
||||
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
prefix_command,
|
||||
rename = "reload_cfg",
|
||||
category = "owner",
|
||||
owners_only,
|
||||
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
|
||||
)]
|
||||
/// Reloads the entire config file.
|
||||
pub async fn cmd(
|
||||
ctx: Context<'_>
|
||||
) -> Result<(), Error>
|
||||
{
|
||||
let r = read_cfg_data(ctx.data(), false).await;
|
||||
let d = get_toml_mutex(&ctx.data().cfg).await.unwrap();
|
||||
|
||||
if r.is_none() { return Ok(()); }
|
||||
|
||||
let data_binding = get_toml_mutex(&ctx.data().cfg).await.unwrap();
|
||||
let lang_cfg = data_binding["general"]["lang"].as_str().unwrap();
|
||||
data::load_lang_data(lang_cfg.to_string());
|
||||
|
||||
if r.unwrap()["value"].as_bool().unwrap() {
|
||||
send_msg(
|
||||
ctx,
|
||||
lang!("dc_msg_reload_cfg_success", toml::to_string_pretty(&d).unwrap()),
|
||||
true,
|
||||
true
|
||||
).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
send_msg(ctx, lang!("dc_msg_reload_cfg_python_fail"), true, true).await;
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
use std::process;
|
||||
|
||||
use poise::serenity_prelude::OnlineStatus;
|
||||
|
||||
use crate::{data, lang, messages::{edit_reply, send_msg}, websocket::send_cmd_json, Context, Error};
|
||||
|
||||
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
prefix_command,
|
||||
rename = "stop",
|
||||
category = "owner",
|
||||
owners_only,
|
||||
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
|
||||
)]
|
||||
/// I have security measures, even in developer mode. You wont access this without being a bot "owner".
|
||||
pub async fn cmd(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Type \"i want to stop the bot now\" to confirm."] confirmation: Option<String>,
|
||||
) -> Result<(), Error>
|
||||
{
|
||||
let stop_confirm = "i want to stop the bot now".replace(" ", "");
|
||||
let confirm_formatted = confirmation.unwrap_or_default().to_lowercase().replace(" ", "");
|
||||
let should_stop = ctx.data().args.dev || confirm_formatted == stop_confirm;
|
||||
|
||||
if should_stop {
|
||||
let msg = send_msg(ctx, lang!("dc_msg_owner_data_save"), true, true).await.unwrap();
|
||||
data::write_dc_data(ctx.data()).await;
|
||||
data::write_re_data().await;
|
||||
send_cmd_json("stop_praw", None, true).await;
|
||||
|
||||
edit_reply(ctx, msg, lang!("dc_msg_owner_data_save_complete")).await;
|
||||
ctx.serenity_context().set_presence(None, OnlineStatus::Invisible);
|
||||
ctx.framework().shard_manager.shutdown_all().await;
|
||||
|
||||
process::exit(0);
|
||||
}
|
||||
else {
|
||||
send_msg(ctx, lang!("dc_msg_owner_shutdown_failed_confirmation"), true, true).await;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
use crate::{lang, messages::send_msg, Context, Error};
|
||||
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
prefix_command,
|
||||
rename = "whoami",
|
||||
category = "help",
|
||||
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
|
||||
)]
|
||||
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let data = ctx.data();
|
||||
let uid: u64 = ctx.author().id.into();
|
||||
|
||||
let is_owner = data.owners .contains(&uid);
|
||||
let is_bk_mod = data.bk_mods.contains(&uid);
|
||||
|
||||
send_msg(ctx, lang!("dc_msg_whoami", is_owner, is_bk_mod), true, true).await;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
Reference in New Issue
Block a user