added /debug Save for quickly saving any data

This commit is contained in:
2026-02-28 14:03:35 +01:00
parent be3570af78
commit 98c35d937b
6 changed files with 35 additions and 9 deletions
+7 -3
View File
@@ -1,15 +1,19 @@
### High priority: ### High priority:
- Update LANG system to be more organized
- Add a lot more logging
<!--
- [ ] Reddit bot that scrapes images with tag "Original Art" and posts them in Discord server - [ ] Reddit bot that scrapes images with tag "Original Art" and posts them in Discord server
- [ ] handle dm_on_error cfg - [ ] handle dm_on_error cfg
- [ ] Allow updating the data autonomously and via manual commands. - [ ] Allow updating the data autonomously and via manual commands.
- [ ] 10-minute schedule for updating Discord channel (IMPOSSIBLE / REALLY FUCKING HARD) - [ ] 10-minute schedule for updating Discord channel (IMPOSSIBLE / REALLY FUCKING HARD)
-->
### Medium priority: ### Medium priority:
- [ ] Postfix calculator
- [ ] Postfix generator
- [ ] Random tip (from ByteDice.net/data/loadingScreenTips.json) - [ ] Random tip (from ByteDice.net/data/loadingScreenTips.json)
- [ ] A command that just sends my socials
### Low priority: ### Low priority:
<!--
- [ ] Content update sender - [ ] Content update sender
* Automatically sends sneak peeks (like commit history or manual) of projects when they're updated * Automatically sends sneak peeks (like commit history or manual) of projects when they're updated
-->
+2 -1
View File
@@ -21,8 +21,9 @@
"dc_msg_mandatory_response": "Mandatory response message, please ignore.", "dc_msg_mandatory_response": "Mandatory response message, please ignore.",
"dc_msg_no_perms": "Missing permission in that server: {0}", "dc_msg_no_perms": "Missing permission in that server: {0}",
"dc_msg_not_in_guild": "I am not a part of that guild.", "dc_msg_not_in_guild": "I am not a part of that guild.",
"dc_msg_owner_data_save_complete": "Saving data... Done!\nShutting down...", "dc_msg_owner_data_save_complete": "Saving data... Done!",
"dc_msg_owner_data_save": "Saving data...", "dc_msg_owner_data_save": "Saving data...",
"dc_msg_owner_shutdown": "Shutting down...",
"dc_msg_owner_shutdown_failed_confirmation": "Failed to shut down: Invalid confirmation.", "dc_msg_owner_shutdown_failed_confirmation": "Failed to shut down: Invalid confirmation.",
"dc_msg_re_already_voted": "Couldn't cast a vote: You have already voted on this post!", "dc_msg_re_already_voted": "Couldn't cast a vote: You have already voted on this post!",
"dc_msg_re_also_approved": "Also approved it!", "dc_msg_re_also_approved": "Also approved it!",
+4 -2
View File
@@ -1,4 +1,4 @@
use crate::{Context, Error, debug_cmds::{guild_invite, leave_guild, ping, stop, view_guilds, whoami}}; use crate::{Context, Error, debug_cmds::{guild_invite, leave_guild, ping, save, stop, view_guilds, whoami}};
#[derive(poise::ChoiceParameter, PartialEq)] #[derive(poise::ChoiceParameter, PartialEq)]
@@ -7,6 +7,7 @@ pub enum Subcommands {
LeaveGuild, LeaveGuild,
Ping, Ping,
//ReloadCfg, //ReloadCfg,
Save,
Stop, Stop,
ViewGuilds, ViewGuilds,
WhoAmI WhoAmI
@@ -35,7 +36,8 @@ pub async fn cmd(
Subcommands::GuildInvite => guild_invite::cmd(ctx, u64_arg_u).await?, Subcommands::GuildInvite => guild_invite::cmd(ctx, u64_arg_u).await?,
Subcommands::LeaveGuild => leave_guild::cmd(ctx, u64_arg_u).await?, Subcommands::LeaveGuild => leave_guild::cmd(ctx, u64_arg_u).await?,
Subcommands::Ping => ping::cmd(ctx).await?, Subcommands::Ping => ping::cmd(ctx).await?,
//Subcommands::ReloadCfg => reload_cfg::cmd(ctx).await?, //Subcommands::ReloadCfg => reload_cfg::cmd(ctx).await?,
Subcommands::Save => save::cmd(ctx).await?,
Subcommands::Stop => stop::cmd(ctx, string_arg).await?, Subcommands::Stop => stop::cmd(ctx, string_arg).await?,
Subcommands::ViewGuilds => view_guilds::cmd(ctx).await?, Subcommands::ViewGuilds => view_guilds::cmd(ctx).await?,
Subcommands::WhoAmI => whoami::cmd(ctx).await?, Subcommands::WhoAmI => whoami::cmd(ctx).await?,
+12
View File
@@ -0,0 +1,12 @@
use crate::{Context, Error, data, lang, messages::{edit_reply, send_msg}};
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
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;
edit_reply(ctx, msg, lang!("dc_msg_owner_data_save_complete")).await;
return Ok(());
}
+8 -2
View File
@@ -4,7 +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>{ pub async fn cmd(ctx: Context<'_>, 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;
@@ -15,7 +15,13 @@ pub async fn cmd(ctx: Context<'_>, confirmation: Option<String>) -> Result<(), E
data::write_re_data().await; data::write_re_data().await;
send_cmd_json("stop_praw", None, true).await; send_cmd_json("stop_praw", None, true).await;
edit_reply(ctx, msg, lang!("dc_msg_owner_data_save_complete")).await; let complete = format!(
"{}\n{}",
lang!("dc_msg_owner_data_save_complete"),
lang!("dc_msg_owner_shutdown")
);
edit_reply(ctx, msg, complete).await;
ctx.serenity_context().set_presence(None, OnlineStatus::Invisible); ctx.serenity_context().set_presence(None, OnlineStatus::Invisible);
ctx.framework().shard_manager.shutdown_all().await; ctx.framework().shard_manager.shutdown_all().await;
+2 -1
View File
@@ -24,9 +24,10 @@ mod debug_cmds {
pub mod guild_invite; pub mod guild_invite;
pub mod leave_guild; pub mod leave_guild;
pub mod main_cmd; pub mod main_cmd;
pub mod stop;
pub mod ping; pub mod ping;
pub mod reload_cfg; pub mod reload_cfg;
pub mod save;
pub mod stop;
pub mod view_guilds; pub mod view_guilds;
pub mod whoami; pub mod whoami;
} }