mirror of
https://github.com/Noratrieb/killjoy-turret.git
synced 2026-01-14 14:45: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::model::prelude::*;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub struct AutoRoleDataKey;
|
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() {
|
if let Some(emote) = answer.content.split(' ').next() {
|
||||||
println!("should add emote: {} for role {}", emote, role.0);
|
println!("should add emote: {} for role {}", emote, role.0);
|
||||||
answer.react(http, '☑').await?;
|
answer.react(http, '☑').await?;
|
||||||
|
match role.to_role_cached(&ctx).await {
|
||||||
roles.push((emote.to_string(), role.0));
|
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 {
|
} else {
|
||||||
break;
|
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?;
|
msg.channel_id.say(http, "done").await?;
|
||||||
|
|
||||||
target_channel
|
let reaction_message = target_channel
|
||||||
.send_message(http, |m| {
|
.send_message(http, |m| {
|
||||||
m.embed(|e| {
|
m.embed(|e| {
|
||||||
e.title(message);
|
e.title(message).fields(
|
||||||
e.field("neutral", "same", false)
|
roles
|
||||||
|
.iter()
|
||||||
|
.map(|(emote, role)| (&role.name, format!("<:{}:{}>", emote.name, emote.id), true)),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
for data in roles {
|
||||||
|
reaction_message.react(http, data.0).await?;
|
||||||
|
}
|
||||||
|
|
||||||
let mut data = ctx.data.write().await;
|
let mut data = ctx.data.write().await;
|
||||||
let mut auto_roles = data.get_mut::<AutoRoleDataKey>().unwrap();
|
let mut auto_roles = data.get_mut::<AutoRoleDataKey>().unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue