add discossiate command & fixes

This commit is contained in:
Matthieu Jolimaitre 2024-08-13 01:48:49 +02:00
parent d6b3b6830a
commit 80fd2ac842
3 changed files with 77 additions and 16 deletions

View file

@ -61,8 +61,9 @@ class Service {
// for all received associations, trigger the association procedure.
(async () => {
for await (const { discord_user_id, cri_login, callback } of this.bot.receive_associations()) {
this.association_procedure(discord_user_id, cri_login).then(callback);
for await (const req of this.bot.receive_associations()) {
if (req.kind === "associate") this.association_procedure(req.discord_user_id, req.cri_login).then(req.callback);
if (req.kind === "dissociate") this.dissociation_procedure(req.discord_user_id).then(req.callback);
}
})();
@ -121,6 +122,11 @@ class Service {
}
return true;
}
async dissociation_procedure(discord_user_id: string): Promise<SimpleResult> {
await this.state.remove_user(discord_user_id);
return true;
}
}
// bot.assign_role_to_member("358338548174159873", "871777993922588712", "1202346358867238952");