Add app data structures

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

View file

@ -1,27 +1,49 @@
use anyhow::Context as _; use anyhow::Context as _;
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;
struct Data {} // User data, which is stored and accessible in all command invocations mod cmds;
type Error = Box<dyn std::error::Error + Send + Sync>; mod db;
mod ea;
mod routes;
mod service;
mod verify;
/// Buttons to (de-)register application commands globally or by guild /// Program data, which is stored and accessible in all command invocations
#[poise::command(prefix_command)] struct Data {
async fn register(ctx: poise::Context<'_, Data, Error>) -> Result<(), Error> { au_ch_id: serenity::ChannelId,
poise::builtins::register_application_commands_buttons(ctx).await?; db: sqlx::PgPool,
Ok(()) ea_key: String,
ea_url: String,
fresher: serenity::RoleId,
member: serenity::RoleId,
} }
/// Send (customisable) verification introduction message in specified channel type ACtx<'a> = poise::ApplicationContext<'a, Data, Error>;
#[poise::command(slash_command)] type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
async fn setup(
ctx: poise::Context<'_, Data, Error>, #[derive(Debug)]
#[description = "Channel to send verification introduction message in"] struct Member {
#[channel_types("Text", "News")] discord_id: i64,
channel: serenity::GuildChannel, shortcode: String,
) -> Result<(), Error> { nickname: String,
let resp = format!("You selected channel: {}", channel); realname: String,
ctx.say(resp).await?; fresher: bool,
Ok(()) }
#[derive(Debug)]
struct PendingMember {
discord_id: i64,
shortcode: String,
realname: String,
}
#[derive(Debug)]
struct ManualMember {
discord_id: i64,
shortcode: String,
nickname: String,
realname: String,
fresher: bool,
} }
#[shuttle_runtime::main] #[shuttle_runtime::main]