feat: Initialized Discord bot
- Bump version to 0.6.0 - discord: Added /quest list - discord: Added /quest create (admin)
This commit is contained in:
parent
2960b6dfc4
commit
5fa2ac330f
8 changed files with 2334 additions and 12 deletions
43
discord/src/main.rs
Normal file
43
discord/src/main.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use clap::Parser;
|
||||
use dotenvy::dotenv;
|
||||
use poise::serenity_prelude as serenity;
|
||||
use squad_quest::config::Config;
|
||||
|
||||
mod commands;
|
||||
mod cli;
|
||||
|
||||
struct Data {
|
||||
pub config: Config,
|
||||
}
|
||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv().unwrap();
|
||||
|
||||
let cli = cli::Cli::parse();
|
||||
let config = Config::load(cli.config.clone());
|
||||
|
||||
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
||||
let intents = serenity::GatewayIntents::non_privileged();
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
commands: vec![commands::quest::quest(), commands::register()],
|
||||
..Default::default()
|
||||
})
|
||||
.setup(|ctx, _ready, framework| {
|
||||
Box::pin(async move {
|
||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
Ok(Data {config})
|
||||
})
|
||||
})
|
||||
.build();
|
||||
|
||||
let client = serenity::ClientBuilder::new(token, intents)
|
||||
.framework(framework)
|
||||
.await;
|
||||
client.unwrap().start().await.unwrap();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue