mirror of
https://github.com/Noratrieb/killjoy-turret.git
synced 2026-01-14 22:55:01 +01:00
sends the message
This commit is contained in:
parent
2416a28b09
commit
9e34b1a6a0
1 changed files with 30 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ use serenity::framework::standard::{
|
|||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct AutoRoleDataKey;
|
||||
|
|
@ -65,8 +66,20 @@ async fn autorole(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
if let Some(emote) = answer.content.split(' ').next() {
|
||||
println!("should add emote: {} for role {}", emote, role.0);
|
||||
answer.react(http, '☑').await?;
|
||||
|
||||
roles.push((emote.to_string(), role.0));
|
||||
match role.to_role_cached(&ctx).await {
|
||||
Some(role) => match EmojiIdentifier::from_str(emote) {
|
||||
Ok(emojiIdent) => roles.push((emojiIdent, role)),
|
||||
Err(_) => {
|
||||
answer.channel_id.say(http, "Could not find emoji").await?;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
answer
|
||||
.channel_id
|
||||
.say(http, "Could not find role, try again or use another role")
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
@ -75,17 +88,29 @@ async fn autorole(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
}
|
||||
}
|
||||
|
||||
if roles.len() == 0 {
|
||||
msg.channel_id.say(http, "No roles were entered.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
msg.channel_id.say(http, "done").await?;
|
||||
|
||||
target_channel
|
||||
let reaction_message = target_channel
|
||||
.send_message(http, |m| {
|
||||
m.embed(|e| {
|
||||
e.title(message);
|
||||
e.field("neutral", "same", false)
|
||||
e.title(message).fields(
|
||||
roles
|
||||
.iter()
|
||||
.map(|(emote, role)| (&role.name, format!("<:{}:{}>", emote.name, emote.id), true)),
|
||||
)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
|
||||
for data in roles {
|
||||
reaction_message.react(http, data.0).await?;
|
||||
}
|
||||
|
||||
let mut data = ctx.data.write().await;
|
||||
let mut auto_roles = data.get_mut::<AutoRoleDataKey>().unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue