feat(discord)!: Added string formatter
- Added string formatter - Added Strings struct for passing strings from file - Refactored /info and /quest * to use formatter BREAKING CHANGE: Changed DiscordConfig fields
This commit is contained in:
parent
b6ea2d8958
commit
aec4ef8339
7 changed files with 386 additions and 84 deletions
|
|
@ -5,20 +5,23 @@ use dotenvy::dotenv;
|
|||
use poise::serenity_prelude as serenity;
|
||||
use squad_quest::config::Config;
|
||||
|
||||
use crate::{commands::error_handler, config::{ConfigImpl, DiscordConfig}, error::Error};
|
||||
use crate::{commands::error_handler, config::{ConfigImpl, DiscordConfig}, error::Error, strings::Strings};
|
||||
|
||||
mod commands;
|
||||
mod cli;
|
||||
mod config;
|
||||
mod account;
|
||||
mod error;
|
||||
mod strings;
|
||||
|
||||
const CONFIG_PATH: &str = "cfg/config.toml";
|
||||
const DISCORD_TOKEN: &str = "DISCORD_TOKEN";
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Data {
|
||||
pub config: Config,
|
||||
pub discord: Arc<Mutex<DiscordConfig>>,
|
||||
pub strings: Strings,
|
||||
}
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
|
||||
|
|
@ -28,12 +31,12 @@ async fn main() {
|
|||
|
||||
let cli = cli::Cli::parse();
|
||||
let config = Config::load(cli.config.clone().unwrap_or(CONFIG_PATH.into()));
|
||||
let discord = config.discord_impl().unwrap_or_else(|_| {
|
||||
let (discord, strings) = config.discord_impl().unwrap_or_else(|_| {
|
||||
config.init_impl().unwrap();
|
||||
config.discord_impl().unwrap()
|
||||
});
|
||||
|
||||
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
||||
let token = std::env::var(DISCORD_TOKEN).expect("missing DISCORD_TOKEN");
|
||||
let intents = serenity::GatewayIntents::non_privileged();
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
|
|
@ -60,6 +63,7 @@ async fn main() {
|
|||
Ok(Data {
|
||||
config,
|
||||
discord: Arc::new(Mutex::new(discord)),
|
||||
strings,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue