Add rudimentary support for role assignment via reactions

This commit is contained in:
kageru 2021-11-20 16:01:23 +01:00
parent 0fbefe2b30
commit 1ee9233e05
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
3 changed files with 1597 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
secret

1563
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ use serenity::framework::standard::{
macros::{command, group},
CommandResult, StandardFramework,
};
use serenity::model::channel::{Reaction, ReactionType};
use serenity::model::{
channel::Message,
id::{ChannelId, GuildId, UserId},
@ -47,6 +48,38 @@ impl EventHandler for Handler {
});
}
}
async fn reaction_add(&self, ctx: Context, reaction: Reaction) {
if reaction.message_id == 911630315376738384
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
{
reaction
.guild_id
.unwrap()
.member(&ctx, reaction.user_id.unwrap())
.await
.unwrap()
.add_role(&ctx, 356421827708321795)
.await
.unwrap()
}
}
async fn reaction_remove(&self, ctx: Context, reaction: Reaction) {
if reaction.message_id == 911630315376738384
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
{
reaction
.guild_id
.unwrap()
.member(&ctx, reaction.user_id.unwrap())
.await
.unwrap()
.remove_role(&ctx, 356421827708321795)
.await
.unwrap()
}
}
}
fn read_token() -> io::Result<String> {