Add commands, setup function and secrets

This commit is contained in:
Aadi Desai 2023-09-24 01:59:09 +01:00
parent 3242544631
commit d02201832b
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM

View file

@ -49,28 +49,72 @@ struct ManualMember {
#[shuttle_runtime::main] #[shuttle_runtime::main]
async fn poise( async fn poise(
#[shuttle_secrets::Secrets] secret_store: shuttle_secrets::SecretStore, #[shuttle_secrets::Secrets] secret_store: shuttle_secrets::SecretStore,
// #[shuttle_shared_db::Postgres] _pool: sqlx::PgPool, // Load secrets
) -> shuttle_poise::ShuttlePoise<Data, Error> { let au_ch_id = secret_store
Ok(poise::Framework::builder() .get("AU_CHANNEL_ID")
.expect("AU_CHANNEL_ID not found")
.parse()
.expect("AU_CHANNEL_ID not valid u64");
let ea_key = secret_store
.get("EA_API_KEY")
.expect("EA_API_KEY not found");
let ea_url = secret_store
.get("EA_API_URL")
.expect("EA_API_URL not found");
let token = secret_store
.get("DISCORD_TOKEN")
.expect("DISCORD_TOKEN not found");
let fresher = secret_store
.get("FRESHER_ID")
.expect("FRESHER_ID not found")
.parse()
.expect("FRESHER_ID not valid u64");
let member = secret_store
.get("MEMBER_ID")
.expect("MEMBER_ID not found")
.parse()
.expect("MEMBER_ID not valid u64");
.options(poise::FrameworkOptions { .options(poise::FrameworkOptions {
commands: vec![register(), setup()], commands: vec![
cmds::cmds(),
cmds::setup(),
cmds::count_members(),
cmds::delete_member(),
cmds::get_all_members(),
cmds::get_member(),
cmds::add_member(),
cmds::insert_member_from_pending(),
cmds::insert_member_from_manual(),
cmds::count_pending(),
cmds::delete_pending(),
cmds::get_all_pending(),
cmds::get_pending(),
cmds::add_pending(),
cmds::delete_all_pending(),
cmds::count_manual(),
cmds::delete_manual(),
cmds::get_all_manual(),
cmds::get_manual(),
cmds::add_manual(),
cmds::delete_all_manual(),
],
event_handler: { |c, e, f, d| Box::pin(event_handler(c, e, f, d)) },
..Default::default() ..Default::default()
}) })
.token( .token(token)
secret_store
.get("DISCORD_TOKEN")
.context("DISCORD_TOKEN not found")?,
)
.intents(serenity::GatewayIntents::non_privileged()) .intents(serenity::GatewayIntents::non_privileged())
.setup(|_, _, _| Box::pin(async { Ok(Data {}) })) .setup(move |ctx, _, _| {
.build() Box::pin(async move {
.await ctx.set_activity(serenity::Activity::competing("autoverification"))
.map_err(shuttle_runtime::CustomError::new)? .await;
.into()) Ok(Data {
} au_ch_id,
db: pool,
// Links for info: ea_key,
// https://github.com/serenity-rs/poise ea_url,
// https://github.com/serenity-rs/poise/tree/current/examples fresher,
// https://github.com/shuttle-hq/shuttle-examples/blob/main/poise/hello-world/src/main.rs member,
// https://github.com/rust-community-discord/ferrisbot-for-discord/blob/main/src/main.rs#L154 })
})
});