You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.5 KiB
78 lines
2.5 KiB
mod commands;
|
|
mod utils;
|
|
|
|
use std::env;
|
|
|
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
|
type Context<'a> = poise::Context<'a, Data, Error>;
|
|
// type PrefixContext<'a> = poise::PrefixContext<'a, Data, Error>;
|
|
// User data, which is stored and accessible in all command invocations
|
|
pub struct Data {}
|
|
|
|
use commands::{challenge::*, kanji::*, meta::*, owner::*};
|
|
use poise::serenity_prelude as serenity;
|
|
use poise::serenity_prelude::model::gateway::GatewayIntents;
|
|
|
|
#[poise::command(prefix_command)]
|
|
async fn register(ctx: Context<'_>) -> Result<(), Error> {
|
|
poise::builtins::register_application_commands_buttons(ctx).await?;
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
// This will load the environment variables located at `./.env`, relative to
|
|
// the CWD. See `./.env.example` for an example on how to structure this.
|
|
dotenv::dotenv().expect("Failed to load .env file");
|
|
|
|
// Initialize the logger to use environment variables.
|
|
//
|
|
// In this case, a good default is setting the environment variable
|
|
// `RUST_LOG` to `debug`.
|
|
|
|
let framework = poise::Framework::builder()
|
|
.options(poise::FrameworkOptions {
|
|
commands: vec![
|
|
register(),
|
|
// owner
|
|
sleep(),
|
|
setsubmissionchannel(),
|
|
setsuggestionchannel(),
|
|
setannouncementrole(),
|
|
announce(),
|
|
announcechallenge(),
|
|
// challenge
|
|
challenge(),
|
|
submit(),
|
|
images(),
|
|
imagedelete(),
|
|
suggest(),
|
|
// meta
|
|
help(),
|
|
// kanji
|
|
i(),
|
|
joyo(),
|
|
jinmeiyo(),
|
|
kyoiku(),
|
|
jlpt(),
|
|
hyogai(),
|
|
so(),
|
|
],
|
|
prefix_options: poise::PrefixFrameworkOptions {
|
|
prefix: Some(env::var("PREFIX").expect("Expected a prefix in the environment")),
|
|
..Default::default()
|
|
},
|
|
..Default::default()
|
|
})
|
|
.token(std::env::var("DISCORD_TOKEN").expect("Expected a token in the environment"))
|
|
.intents(
|
|
GatewayIntents::GUILD_MESSAGES
|
|
| GatewayIntents::DIRECT_MESSAGES
|
|
| GatewayIntents::MESSAGE_CONTENT
|
|
| GatewayIntents::GUILDS,
|
|
)
|
|
.setup(move |_ctx, _ready, _framework| Box::pin(async move { Ok(Data {}) }));
|
|
|
|
framework.run().await.unwrap();
|
|
}
|