From ec74dc0aa71ccae6ded8271fca10481840596bb3 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 29 Sep 2024 21:04:08 +0100 Subject: [PATCH] prep: skeleton to handle roles changing from other means --- src/main.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f1c70f3..413dc6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use serenity::{ Client, }; use std::sync::Arc; - +use serenity::model::guild::Member; use skynet_discord_bot::{db_init, get_config, get_server_config, get_server_member, Config, DataBase}; use tokio::sync::RwLock; @@ -21,6 +21,7 @@ struct Handler; #[async_trait] impl EventHandler for Handler { + // handles previously linked accounts joining the server async fn guild_member_addition(&self, ctx: Context, mut new_member: guild::Member) { let db_lock = { let data_read = ctx.data.read().await; @@ -120,6 +121,25 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use } } } + + // handles role updates + async fn guild_member_update(&self, _ctx: Context, _old_if_available: Option, _new: Member){ + if let Some(x) = _old_if_available { + if x.roles.len() != _new.roles.len() { + return; + } + //do we need to do more comparison here? + } + + + // get config/db + + // check if the role changed is part of the oens for this server + + // if so add or remove the resultant one + + // TODO: Finish + } } #[tokio::main]