diff --git a/data/lang/en.json b/data/lang/en.json index 813e74f..d3ad2fc 100644 --- a/data/lang/en.json +++ b/data/lang/en.json @@ -1,6 +1,7 @@ { "generic": { - "none": "None" + "none": "None", + "success": "Success!" }, "dc": { "re": { @@ -37,7 +38,14 @@ "added_server": "Added your server to my database. Thanks for letting me steal it! (/s)", "corrupted_data": "Couldn't add your server to the database! The database is corrupted!", "server_404": "This server is not in the data!\n-# Hint: Run the command `/database AddServer` inside of a Discord server (requires administrator permission).", - "channel_bind": "Successfully added channel ID `{0}` to the database!" - } + "channel_bind": "Successfully added channel ID `{0}` to the database!", + "not_in_guild": "I am not a part of that guild.", + "saving_progress": "Saving data...", + "saving_done": "Saving data... Done!" + }, + "no_perms_external": "Missing permission in that server: {0}", + "shutdown": "Shutting down...", + "shutdown_bad_confirm": "Failed to shut down: Invalid confirmation.", + "whoami": "**Bot \"owner\":** {0}\n**BK moderator:** {1}" } } \ No newline at end of file diff --git a/data/lang/en_deprecated.json b/data/lang/en_deprecated.json index ec47d1e..8e0da18 100644 --- a/data/lang/en_deprecated.json +++ b/data/lang/en_deprecated.json @@ -19,11 +19,11 @@ "dc_msg_err_trace": "Unknown error!\nError trace: {0}", "dc_msg_failed_shorturl_conversion": "Couldn't convert to shortURL: Invalid Reddit URL format.", "dc_msg_mandatory_response": "Mandatory response message, please ignore.", - "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_owner_data_save_complete": "Saving data... Done!", - "dc_msg_owner_data_save": "Saving data...", - "dc_msg_owner_shutdown": "Shutting down...", + //"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_owner_data_save_complete": "Saving data... Done!", + //"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_re_already_voted": "Couldn't cast a vote: You have already voted on this post!", "dc_msg_re_also_approved": "Also approved it!", @@ -58,7 +58,7 @@ "dc_msg_update_removing_dupe": "{0}Removing duplicate posts...", "dc_msg_update_removing_old": "{0}Removing old posts (threshold: {1}d)...", "dc_msg_update_removing": "{0}Removing removed posts...", - "dc_msg_whoami": "**Bot \"owner\":** {0}\n**BK moderator:** {1}", + //"dc_msg_whoami": "**Bot \"owner\":** {0}\n**BK moderator:** {1}", "dc_msg_wwrps_already_submitted": "You can't compete against yourself! Please wait until another player has submitted their RPS.", "dc_msg_wwrps_anon": "[Anonymous]", "dc_msg_wwrps_draw": "DRAW", @@ -68,11 +68,11 @@ "dc_msg_wwrps_right_win": "P2 WINS", "dc_msg_wwrps_submitting": "Submitting your RPS... Please wait for another contestant to compete against you.", "log_lang_load_success": "Successfully loaded the english language file!", - "none": "None", + //"none": "None", "py_re_response_suffix": "^(I am not an AI, I am just a bot. This action was performed automatically by the way. You can report bugs and view my source code [here](https://github.com/ByteDice/ByteDiceAssistant)!)", "py_re_response_weekly_add": "Successfully added your post to the weekly art submissions! Thank you for participating!", "py_re_response_weekly_exists": "Couldn't add this post to the submissions! Luckily, it's already there! Thank you for participating!", "py_re_response_weekly_mod_add": "[MOD ACTION] Successfully added this post to the weekly art submissions!", "py_re_response_weekly_mod_unremove": "[MOD ACTION] Successfully un-removed this post from the weekly art submissions!", - "success": "Success!" + //"success": "Success!" } \ No newline at end of file diff --git a/src/cmds/debug/guild_invite.rs b/src/cmds/debug/guild_invite.rs index 634e07d..42d5fd3 100644 --- a/src/cmds/debug/guild_invite.rs +++ b/src/cmds/debug/guild_invite.rs @@ -1,6 +1,6 @@ use poise::serenity_prelude::{CreateInvite, GuildId}; -use crate::{Context, Error, lang, messages::send_msg}; +use crate::{Context, Error, messages::send_msg}; pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> { @@ -8,7 +8,7 @@ pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> { let guild = id.to_partial_guild(ctx.http()).await?; if !ctx.serenity_context().cache.guilds().contains(&id) { - send_msg(ctx, lang!("dc_msg_not_in_guild"), true, true).await; + send_msg(ctx, ctx.data().lang.get("dc.db.not_in_guild", &[]), true, true).await; return Ok(()); } @@ -22,7 +22,12 @@ pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> { let perms = guild.user_permissions_in(&channel, bot_member); if !perms.create_instant_invite() { - send_msg(ctx, lang!("dc_msg_no_perms", "CreateInvite"), true, true).await; + send_msg( + ctx, + ctx.data().lang.get("dc.no_perms_external", &["CreateInvite".to_string()]), + true, + true + ).await; return Ok(()); } diff --git a/src/cmds/debug/leave_guild.rs b/src/cmds/debug/leave_guild.rs index c86e790..8e5e0f4 100644 --- a/src/cmds/debug/leave_guild.rs +++ b/src/cmds/debug/leave_guild.rs @@ -1,6 +1,6 @@ use poise::serenity_prelude::GuildId; -use crate::{Context, Error, lang, messages::send_msg}; +use crate::{Context, Error, messages::send_msg}; pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> { @@ -8,12 +8,12 @@ pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> { let guild = id.to_partial_guild(ctx.http()).await?; if !ctx.serenity_context().cache.guilds().contains(&id) { - send_msg(ctx, lang!("dc_msg_not_in_guild"), true, true).await; + send_msg(ctx, ctx.data().lang.get("dc.db.not_in_guild", &[]), true, true).await; return Ok(()); } guild.leave(ctx.http()).await?; - send_msg(ctx, lang!("success"), true, true).await; + send_msg(ctx, ctx.data().lang.get("generic.success", &[]), true, true).await; return Ok(()); } \ No newline at end of file diff --git a/src/cmds/debug/save.rs b/src/cmds/debug/save.rs index b018c8e..483de85 100644 --- a/src/cmds/debug/save.rs +++ b/src/cmds/debug/save.rs @@ -1,12 +1,17 @@ -use crate::{Context, Error, db::{discord, reddit}, lang, messages::{edit_reply, send_msg}}; +use crate::{Context, Error, db::{discord, reddit}, 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(); + let msg = send_msg( + ctx, + ctx.data().lang.get("dc.db.saving_progress", &[]), + true, + true + ).await.unwrap(); discord::write_data(ctx.data()).await; reddit ::write_data().await; - edit_reply(ctx, msg, lang!("dc_msg_owner_data_save_complete")).await; + edit_reply(ctx, msg, ctx.data().lang.get("dc.db.saving_done", &[])).await; return Ok(()); } \ No newline at end of file diff --git a/src/cmds/debug/stop.rs b/src/cmds/debug/stop.rs index 32a85e6..7e1bc80 100644 --- a/src/cmds/debug/stop.rs +++ b/src/cmds/debug/stop.rs @@ -2,7 +2,7 @@ use std::process; use poise::serenity_prelude::OnlineStatus; -use crate::{db::{discord, reddit}, lang, messages::{edit_reply, send_msg}, websocket::send_cmd_json, Context, Error}; +use crate::{db::{discord, reddit}, messages::{edit_reply, send_msg}, websocket::send_cmd_json, Context, Error}; pub async fn cmd(ctx: Context<'_>, confirmation: Option) -> Result<(), Error> { let stop_confirm = "i want to stop the bot now".replace(" ", ""); @@ -10,15 +10,21 @@ pub async fn cmd(ctx: Context<'_>, confirmation: Option) -> Result<(), E 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(); + let msg = send_msg( + ctx, + ctx.data().lang.get("dc.db.saving_progress", &[]), + true, + true + ).await.unwrap(); + discord::write_data(ctx.data()).await; reddit ::write_data().await; send_cmd_json("stop_praw", None, true).await; let complete = format!( "{}\n{}", - lang!("dc_msg_owner_data_save_complete"), - lang!("dc_msg_owner_shutdown") + ctx.data().lang.get("dc.db.saving_done", &[]), + ctx.data().lang.get("dc.shutdown", &[]) ); edit_reply(ctx, msg, complete).await; @@ -27,9 +33,7 @@ pub async fn cmd(ctx: Context<'_>, confirmation: Option) -> Result<(), E process::exit(0); } - else { - send_msg(ctx, lang!("dc_msg_owner_shutdown_failed_confirmation"), true, true).await; - } + else { send_msg(ctx, ctx.data().lang.get("dc.shutdown_bad_confirm", &[]), true, true).await; } return Ok(()); } \ No newline at end of file diff --git a/src/cmds/debug/whoami.rs b/src/cmds/debug/whoami.rs index 65a8798..23b1d3e 100644 --- a/src/cmds/debug/whoami.rs +++ b/src/cmds/debug/whoami.rs @@ -1,4 +1,4 @@ -use crate::{lang, messages::send_msg, Context, Error}; +use crate::{messages::send_msg, Context, Error}; pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> { let data = ctx.data(); @@ -7,7 +7,12 @@ pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> { let is_owner = data.env_vars.bot_owners.contains(&uid); let is_bk_mod = data.env_vars.reddit_mod_discord_ids.contains(&uid); - send_msg(ctx, lang!("dc_msg_whoami", is_owner, is_bk_mod), true, true).await; + send_msg( + ctx, + ctx.data().lang.get("dc.whoami", &[is_owner.to_string(), is_bk_mod.to_string()]), + true, + true + ).await; return Ok(()); } \ No newline at end of file