cmds/generic/ LANG migration

This commit is contained in:
2026-03-05 14:34:51 +01:00
parent 0836131045
commit afa966804f
7 changed files with 55 additions and 33 deletions
+16 -2
View File
@@ -32,20 +32,34 @@
"embed": {
"post": "Spoilers and vote length anonymizer for fair review!\n## Post Data:\n**Subreddit:** {0}\n**Post upvotes:** ||`{1:>6}`||\n**Moderator votes:** ||`{2:>6}`||\n**Media type:** `{3}`\n## Listing Data:\n**Added by:** human: {4} | bot: {5}\n**Approved:** {6}",
"post_removed": "## Removed by `{0}`\n**Reason:** {1}"
}
},
"help_404": "Reddit help file not found, someone likely deleted it.\n Hint: You can find the official help text at https://github.com/ByteDice/ByteDiceAssistant in `re_help.md`.\n**CAUTION:** The official help file may contain incorrect information if you're not using the official bot by Byte Dice."
},
"db": {
"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).",
"wwrps_404": "Could not find `wwrps_channel` in data!\n-# Hint: Run `/database WWRPSChannel` in a channel (requires administrator permission).",
"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!"
},
"wwrps": {
"submitting": "Submitting your RPS... Please wait for another contestant to compete against you.",
"already_submitted": "You can't compete against yourself! Please wait until another player has submitted their RPS.",
"anon": "[Anonymous]",
"draw": "DRAW",
"match": "### {0} (P1) vs {1} (P2)...\n## {2}\n**P1:** {3}\n**P2:** {4}",
"p1_win": "P1 WINS",
"p2_win": "P2 WINS"
},
"8_ball": "**8-ball Question:** {0}\n**Answer:** {1}",
"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}"
"whoami": "**Bot \"owner\":** {0}\n**BK moderator:** {1}",
"mandatory_response": "Mandatory response message, please ignore.",
"cmd_404": "No command \"{0}\" found!\nHint: Try `/help` without any arguments or `/help <category>`"
}
}
+10 -10
View File
@@ -5,10 +5,10 @@
//"dc_btn_unremove": "Restore",
//"dc_btn_unvote": "Un-vote",
//"dc_btn_vote": "Vote",
"dc_msg_8-ball_answer": "**8-ball Question:** {0}\n**Answer:** {1}",
//"dc_msg_8-ball_answer": "**8-ball Question:** {0}\n**Answer:** {1}",
//"dc_msg_add_to_data": "Added your server to my data! Thanks for letting me steal it! (/s)",
//"dc_msg_bound_channel": "Successfully added channel ID `{0}` to the database!",
"dc_msg_cmd_404": "No command \"{0}\" found!\nHint: Try `/help` without any arguments or `/help <category>`",
//"dc_msg_cmd_404": "No command \"{0}\" found!\nHint: Try `/help` without any arguments or `/help <category>`",
//"dc_msg_corrupted_data": "Oopsies `(。>\\\\<)`. It looks like my data i-is \\**sob*\\*... c-corrupted!",
//"dc_msg_data_server_404": "This server is not in the data!\n Hint: Run the command `/database AddServer` inside of a Discord server (requires administrator permission).",
//"dc_msg_dm_python_err_socket": "Unknown internal Python error occurred: Websocket response error",
@@ -59,14 +59,14 @@
"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_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",
"dc_msg_wwrps_fight": "### {0} (P1) vs {1} (P2)...\n## {2}\n**P1:** {3}\n**P2:** {4}",
"dc_msg_wwrps_not_in_data": "Could not find `wwrps_channel` in data!\nHint: Run `/database WWRPSChannel` in a channel (requires administrator permission).",
"dc_msg_wwrps_left_win": "P1 WINS",
"dc_msg_wwrps_right_win": "P2 WINS",
"dc_msg_wwrps_submitting": "Submitting your RPS... Please wait for another contestant to compete against you.",
//"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",
//"dc_msg_wwrps_fight": "### {0} (P1) vs {1} (P2)...\n## {2}\n**P1:** {3}\n**P2:** {4}",
//"dc_msg_wwrps_not_in_data": "Could not find `wwrps_channel` in data!\nHint: Run `/database WWRPSChannel` in a channel (requires administrator permission).",
//"dc_msg_wwrps_left_win": "P1 WINS",
//"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",
"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)!)",
+2 -2
View File
@@ -1,6 +1,6 @@
use rand::{seq::IteratorRandom, Rng};
use crate::{lang, messages::send_msg, Context, Error};
use crate::{messages::send_msg, Context, Error};
#[poise::command(
@@ -25,7 +25,7 @@ pub async fn cmd(
send_msg(
ctx,
lang!("dc_msg_8-ball_answer", question, rand_item.unwrap()),
ctx.data().lang.get("dc.8_ball", &[question, rand_item.unwrap().to_string()]),
false,
true
).await;
+2 -2
View File
@@ -1,6 +1,6 @@
use poise::serenity_prelude::Timestamp;
use crate::{lang, messages::{send_embed, send_msg, Author, EmbedOptions}, Context, Error};
use crate::{messages::{send_embed, send_msg, Author, EmbedOptions}, Context, Error};
#[allow(clippy::too_many_arguments)]
#[poise::command(
@@ -46,7 +46,7 @@ pub async fn cmd(
).await;
if !reply_unwrap {
send_msg(ctx, lang!("dc_msg_mandatory_response"), true, true).await;
send_msg(ctx, ctx.data().lang.get("dc.mandatory_response", &[]), true, true).await;
}
return Ok(());
+3 -3
View File
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use tokio::fs;
use crate::{lang, messages::send_msg, Context, Cmd, Error};
use crate::{messages::send_msg, Context, Cmd, Error};
#[derive(poise::ChoiceParameter, PartialEq)]
@@ -82,7 +82,7 @@ async fn send_single_help(ctx: Context<'_>, mut cmd_name: String) {
if cmd.is_none() {
send_msg(
ctx,
lang!("dc_msg_cmd_404", cmd_name),
ctx.data().lang.get("dc.cmd_404", &[cmd_name]),
true,
true
).await;
@@ -108,7 +108,7 @@ async fn send_category_help(ctx: Context<'_>, category: HelpOptions) {
async fn send_bk_week_help_re(ctx: Context<'_>) {
let t: String = fs::read_to_string("./bk_week_help_re.md").await
.unwrap_or(lang!("dc_msg_re_help_removed"));
.unwrap_or(ctx.data().lang.get("dc.re.help_404", &[]));
send_msg(ctx, t, true, true).await;
}
+2 -2
View File
@@ -1,4 +1,4 @@
use crate::{lang, messages::send_msg, Context, Error};
use crate::{messages::send_msg, Context, Error};
#[poise::command(
@@ -16,6 +16,6 @@ pub async fn cmd(
) -> Result<(), Error>
{
send_msg(ctx, msg.replace("\\n", "\n"), false, false).await;
send_msg(ctx, lang!("dc_msg_mandatory_response"), true, true).await;
send_msg(ctx, ctx.data().lang.get("dc.mandatory_response", &[]), true, true).await;
return Ok(());
}
+20 -12
View File
@@ -1,7 +1,7 @@
use poise::serenity_prelude::{ChannelId, Mentionable};
use tokio::sync::MutexGuard;
use crate::{Context, Error, games::wwrps::{RPS, RPSGame, RPSPlayer}, lang, messages::{http_send_msg, send_msg}};
use crate::{Context, Error, games::wwrps::{RPS, RPSGame, RPSPlayer}, lang::Lang, messages::{http_send_msg, send_msg}};
#[poise::command(
@@ -20,10 +20,10 @@ pub async fn cmd(
{
let c_o = get_wwrps_channel(ctx).await;
if c_o.is_none() { send_msg(ctx, lang!("dc_msg_wwrps_not_in_data"), true, true).await; return Ok(()); }
if c_o.is_none() { send_msg(ctx, ctx.data().lang.get("dc.db.wwrps_404", &[]), true, true).await; return Ok(()); }
let c = c_o.unwrap();
send_msg(ctx, lang!("dc_msg_wwrps_submitting"), true, true).await;
send_msg(ctx, ctx.data().lang.get("dc.wwrps.submitting", &[]), true, true).await;
let mut game = ctx.data().rps_game.lock().await;
@@ -32,12 +32,12 @@ pub async fn cmd(
RPSPlayer { selection, user: ctx.author().clone(), wwrps_channel: ChannelId::new(c), anonymous });
if let Err(_) = r
{ send_msg(ctx, lang!("dc_msg_wwrps_already_submitted"), true, true).await; return Ok(()); }
{ send_msg(ctx, ctx.data().lang.get("dc.wwrps.already_submitted", &[]), true, true).await; return Ok(()); }
let full = r.unwrap();
if !full { return Ok(()); }
let r_text = results_text(&game);
let r_text = results_text(&game, &ctx.data().lang);
let game_clone = game.clone();
game.clear();
@@ -56,21 +56,29 @@ pub async fn cmd(
}
fn results_text(game: &MutexGuard<'_, RPSGame>) -> String {
fn results_text(game: &MutexGuard<'_, RPSGame>, lang: &Lang) -> String {
let winner = game.get_winner();
let winner_text: String;
let p1 = game.players[0].as_ref().unwrap();
let p2 = game.players[1].as_ref().unwrap();
let p1_n = if !p1.anonymous { p1.user.mention().to_string() } else { lang!("dc_msg_wwrps_anon") };
let p2_n = if !p2.anonymous { p2.user.mention().to_string() } else { lang!("dc_msg_wwrps_anon") };
let p1_n = if !p1.anonymous { p1.user.mention().to_string() } else { lang.get("dc.wwrps.anon", &[]) };
let p2_n = if !p2.anonymous { p2.user.mention().to_string() } else { lang.get("dc.wwrps.anon", &[]) };
if let Some(w) = winner {
winner_text = if w == 0 { lang!("dc_msg_wwrps_left_win") }
else { lang!("dc_msg_wwrps_right_win") }; }
else { winner_text = lang!("dc_msg_wwrps_draw"); }
winner_text = if w == 0 { lang.get("dc.wwrps.p1_win", &[]) }
else { lang.get("dc.wwrps.p2_win", &[]) }; }
else { winner_text = lang.get("dc.wwrps.draw", &[]); }
return lang!("dc_msg_wwrps_fight", p1.selection.clone(), p2.selection.clone(), winner_text, p1_n, p2_n);
return lang.get(
"dc.wwrps.match",
&[
p1.selection.to_string(),
p2.selection.to_string(),
winner_text,
p1_n,
p2_n
]);
}