moved "debug" commands to a single command to reduce clutter
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ flate2 = "1.1.2"
|
|||||||
formatx = "0.2.3"
|
formatx = "0.2.3"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
poise = "0.6.1"
|
poise = "0.6.1"
|
||||||
pyo3 = "0.23.4"
|
pyo3 = "0.28.2"
|
||||||
rand = "0.9.0"
|
rand = "0.9.0"
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
serde = "1.0.217"
|
serde = "1.0.217"
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ lang = "en"
|
|||||||
# The discord bots status text
|
# The discord bots status text
|
||||||
status = "🎲 https://bytedice.net"
|
status = "🎲 https://bytedice.net"
|
||||||
|
|
||||||
|
# Adds "(Commit #123)" at the end of the status
|
||||||
|
statusCommitNumber = true
|
||||||
|
|
||||||
|
# Changes "(Commit #123)" into "(Experimental #123)"
|
||||||
|
# Requires statusCommitNumber to be true
|
||||||
|
statusExperimentalCommit = false
|
||||||
|
|
||||||
[reddit]
|
[reddit]
|
||||||
# Which subreddits the bot will scan when executing "re"-category commands.
|
# Which subreddits the bot will scan when executing "re"-category commands.
|
||||||
# Is automatically disabled when `disabled_categories` includes "re".
|
# Is automatically disabled when `disabled_categories` includes "re".
|
||||||
@@ -31,6 +38,7 @@ disabled_categories = [
|
|||||||
# "fun",
|
# "fun",
|
||||||
# "help"
|
# "help"
|
||||||
# "re"
|
# "re"
|
||||||
|
# "debug"
|
||||||
]
|
]
|
||||||
|
|
||||||
# The chance (between 0..1) for the `/8_ball` command to output a "quirky" answer.
|
# The chance (between 0..1) for the `/8_ball` command to output a "quirky" answer.
|
||||||
|
|||||||
@@ -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(());
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
use crate::{Context, Error, debug_cmds::{ping, reload_cfg, stop, whoami}};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(poise::ChoiceParameter, PartialEq)]
|
||||||
|
pub enum Subcommands {
|
||||||
|
GuildInvite,
|
||||||
|
LeaveGuild,
|
||||||
|
Ping,
|
||||||
|
ReloadCfg,
|
||||||
|
Stop,
|
||||||
|
ViewGuilds,
|
||||||
|
WhoAmI
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[poise::command(
|
||||||
|
slash_command,
|
||||||
|
prefix_command,
|
||||||
|
category = "owner",
|
||||||
|
rename = "debug",
|
||||||
|
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
|
||||||
|
)]
|
||||||
|
/// Various debug utilities
|
||||||
|
pub async fn cmd(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Subcommand"] subcommand: Subcommands,
|
||||||
|
string_arg: Option<String>
|
||||||
|
) -> Result<(), Error>
|
||||||
|
{
|
||||||
|
match subcommand {
|
||||||
|
Subcommands::Ping => ping::cmd(ctx).await?,
|
||||||
|
Subcommands::ReloadCfg => reload_cfg::cmd(ctx).await?,
|
||||||
|
Subcommands::Stop => stop::cmd(ctx, string_arg).await?,
|
||||||
|
Subcommands::WhoAmI => whoami::cmd(ctx).await?,
|
||||||
|
_ => return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
use crate::{messages::send_msg, Context, Error};
|
||||||
|
|
||||||
|
|
||||||
|
pub async fn cmd(ctx: Context<'_>,) -> Result<(), Error> {
|
||||||
|
send_msg(ctx, "Pong".to_string(), true, true).await;
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
@@ -1,19 +1,7 @@
|
|||||||
use crate::{data::{self, get_toml_mutex, read_cfg_data}, lang, messages::send_msg, Context, Error};
|
use crate::{data::{self, get_toml_mutex, read_cfg_data}, lang, messages::send_msg, Context, Error};
|
||||||
|
|
||||||
|
|
||||||
#[poise::command(
|
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
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 r = read_cfg_data(ctx.data(), false).await;
|
||||||
let d = get_toml_mutex(&ctx.data().cfg).await.unwrap();
|
let d = get_toml_mutex(&ctx.data().cfg).await.unwrap();
|
||||||
|
|
||||||
@@ -4,21 +4,7 @@ use poise::serenity_prelude::OnlineStatus;
|
|||||||
|
|
||||||
use crate::{data, lang, messages::{edit_reply, send_msg}, websocket::send_cmd_json, Context, Error};
|
use crate::{data, lang, messages::{edit_reply, send_msg}, websocket::send_cmd_json, Context, Error};
|
||||||
|
|
||||||
|
pub async fn cmd(ctx: Context<'_>, confirmation: Option<String>) -> Result<(), 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 stop_confirm = "i want to stop the bot now".replace(" ", "");
|
||||||
let confirm_formatted = confirmation.unwrap_or_default().to_lowercase().replace(" ", "");
|
let confirm_formatted = confirmation.unwrap_or_default().to_lowercase().replace(" ", "");
|
||||||
let should_stop = ctx.data().args.dev || confirm_formatted == stop_confirm;
|
let should_stop = ctx.data().args.dev || confirm_formatted == stop_confirm;
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
use crate::{lang, messages::send_msg, Context, Error};
|
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> {
|
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
let data = ctx.data();
|
let data = ctx.data();
|
||||||
let uid: u64 = ctx.author().id.into();
|
let uid: u64 = ctx.author().id.into();
|
||||||
+4
-6
@@ -4,7 +4,7 @@ use poise::serenity_prelude::UserId;
|
|||||||
use poise::serenity_prelude as serenity;
|
use poise::serenity_prelude as serenity;
|
||||||
use poise::serenity_prelude::Client;
|
use poise::serenity_prelude::Client;
|
||||||
|
|
||||||
use crate::{cmds, data::{self, get_toml_mutex}, events, re_cmds, rs_println, Args, Cmd, Data};
|
use crate::{Args, Cmd, Data, cmds, data::{self, get_toml_mutex}, debug_cmds, events, re_cmds, rs_println};
|
||||||
|
|
||||||
|
|
||||||
pub async fn gen_data(args: Args, owners: Vec<u64>) -> Data {
|
pub async fn gen_data(args: Args, owners: Vec<u64>) -> Data {
|
||||||
@@ -79,8 +79,6 @@ async fn make_cmd_vec(data: &Data) -> Vec<Cmd> {
|
|||||||
let mut cmds = vec![
|
let mut cmds = vec![
|
||||||
// GENERIC
|
// GENERIC
|
||||||
cmds::help::cmd(),
|
cmds::help::cmd(),
|
||||||
cmds::whoami::cmd(),
|
|
||||||
cmds::ping::cmd(),
|
|
||||||
cmds::eight_ball::cmd(),
|
cmds::eight_ball::cmd(),
|
||||||
// REDDIT
|
// REDDIT
|
||||||
re_cmds::add::cmd(),
|
re_cmds::add::cmd(),
|
||||||
@@ -94,11 +92,11 @@ async fn make_cmd_vec(data: &Data) -> Vec<Cmd> {
|
|||||||
// [ADMIN / OWNER]
|
// [ADMIN / OWNER]
|
||||||
cmds::embed::cmd(),
|
cmds::embed::cmd(),
|
||||||
cmds::send::cmd(),
|
cmds::send::cmd(),
|
||||||
cmds::stop::cmd(),
|
|
||||||
cmds::add_server::cmd(),
|
cmds::add_server::cmd(),
|
||||||
cmds::reload_cfg::cmd(),
|
|
||||||
// REDDIT [ADMIN / OWNER]
|
// REDDIT [ADMIN / OWNER]
|
||||||
re_cmds::admin_bind::cmd()
|
re_cmds::admin_bind::cmd(),
|
||||||
|
// DEBUG
|
||||||
|
debug_cmds::main_cmd::cmd()
|
||||||
];
|
];
|
||||||
let cfg = get_toml_mutex(&data.cfg).await.unwrap();
|
let cfg = get_toml_mutex(&data.cfg).await.unwrap();
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -1,16 +1,13 @@
|
|||||||
#![warn(unused_extern_crates)]
|
#![warn(unused_extern_crates)]
|
||||||
#![allow(clippy::needless_return)]
|
#![allow(clippy::needless_return)]
|
||||||
|
#![allow(static_mut_refs)]
|
||||||
|
|
||||||
mod cmds {
|
mod cmds {
|
||||||
pub mod add_server;
|
pub mod add_server;
|
||||||
pub mod eight_ball;
|
pub mod eight_ball;
|
||||||
pub mod embed;
|
pub mod embed;
|
||||||
pub mod help;
|
pub mod help;
|
||||||
pub mod ping;
|
|
||||||
pub mod reload_cfg;
|
|
||||||
pub mod send;
|
pub mod send;
|
||||||
pub mod stop;
|
|
||||||
pub mod whoami;
|
|
||||||
}
|
}
|
||||||
mod re_cmds {
|
mod re_cmds {
|
||||||
pub mod add;
|
pub mod add;
|
||||||
@@ -24,6 +21,13 @@ mod re_cmds {
|
|||||||
pub mod update;
|
pub mod update;
|
||||||
pub mod vote;
|
pub mod vote;
|
||||||
}
|
}
|
||||||
|
mod debug_cmds {
|
||||||
|
pub mod main_cmd;
|
||||||
|
pub mod stop;
|
||||||
|
pub mod ping;
|
||||||
|
pub mod reload_cfg;
|
||||||
|
pub mod whoami;
|
||||||
|
}
|
||||||
mod events;
|
mod events;
|
||||||
mod messages;
|
mod messages;
|
||||||
mod python;
|
mod python;
|
||||||
|
|||||||
+2
-4
@@ -36,10 +36,8 @@ pub async fn start(args: Args) -> PyResult<()> {
|
|||||||
let mut traceback: String = String::new();
|
let mut traceback: String = String::new();
|
||||||
let mut is_error = false;
|
let mut is_error = false;
|
||||||
|
|
||||||
pyo3::prepare_freethreaded_python();
|
let _ = Python::attach(|py| -> Result<(), PyErr> {
|
||||||
|
let syspath = py.import("sys")?.getattr("path")?.cast_into::<PyList>()?;
|
||||||
let _ = Python::with_gil(|py| -> Result<(), PyErr> {
|
|
||||||
let syspath = py.import("sys")?.getattr("path")?.downcast_into::<PyList>()?;
|
|
||||||
syspath.insert(0, path)?;
|
syspath.insert(0, path)?;
|
||||||
let empty = CString::new("").unwrap();
|
let empty = CString::new("").unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user