use crate::db::users::{user_all, user_insert, User}; use crate::{Context, Error}; #[poise::command(prefix_command, slash_command)] pub async fn register( ctx: Context<'_>, first_name: String, last_name: String, email: String, ) -> Result<(), Error> { let user = User { discord_id: ctx.author().id.0 as i64, first_name, last_name, email, }; { let mut conn = ctx.data().pool.get()?; user_insert(&mut conn, &user); } Ok(()) } #[poise::command(prefix_command, slash_command)] pub async fn registered(ctx: Context<'_>) -> Result<(), Error> { let users = { let mut conn = ctx.data().pool.get()?; user_all(&mut conn) }; ctx.send(|f| { f.embed(|e| { e.description("Registered users").fields( users .into_iter() .map(|u| (format!("{} {}", u.first_name, u.last_name), u.email, false)), ) }) }) .await?; Ok(()) }