feat: Added DiscordConfig for future usage
- Added crate::error::Error::IsNotImplemented - Added Config::full_impl_path - Added Config::discord_impl for discord crate
This commit is contained in:
parent
1142fe6ad9
commit
b92eaa1241
4 changed files with 106 additions and 1 deletions
|
|
@ -3,11 +3,15 @@ use dotenvy::dotenv;
|
|||
use poise::serenity_prelude as serenity;
|
||||
use squad_quest::config::Config;
|
||||
|
||||
use crate::config::{ConfigImpl, DiscordConfig};
|
||||
|
||||
mod commands;
|
||||
mod cli;
|
||||
mod config;
|
||||
|
||||
struct Data {
|
||||
pub config: Config,
|
||||
pub discord: DiscordConfig,
|
||||
}
|
||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
|
|
@ -18,6 +22,7 @@ async fn main() {
|
|||
|
||||
let cli = cli::Cli::parse();
|
||||
let config = Config::load(cli.config.clone());
|
||||
let discord = config.discord_impl().expect("config does not define impl_path");
|
||||
|
||||
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
||||
let intents = serenity::GatewayIntents::non_privileged();
|
||||
|
|
@ -30,7 +35,10 @@ async fn main() {
|
|||
.setup(|ctx, _ready, framework| {
|
||||
Box::pin(async move {
|
||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
Ok(Data {config})
|
||||
Ok(Data {
|
||||
config,
|
||||
discord,
|
||||
})
|
||||
})
|
||||
})
|
||||
.build();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue