KSLI6S43M2RU7MMFOSNUIISHJECRZIP3YVMUXHJBAKYXXDMDE5KAC
SHN4Y2EFD44NK3RJRY57VEHZFUQBREDQE2M4J5PZW2UVGMYP5YUAC
6ZURHACLQ6F3QGSEGRENRUOZWBTRBOAXKHC372AGXXQ7FA7RX6QAC
U2D5BY4KBQLM5NZLWGOTNVYDECYSBHYVGHTWSXSOWYW2NTIMEMTQC
YREDNL3G26AXAUNMTGBRZUMJM3MBZ2TGGJJ5JLIRWBSOTPSEWFHQC
HR7EMS5WWDJASCN25DIFBKTRAESBEPGQDZIGP7DAO7EWXDW2HQSQC
HSHQP542PXUJQVPUFX2YOSI6N4DYZ75VTBOIVJMYJXFSTKKIBDMAC
Y5DIB6C3UMYHI7UVDP442GJCLRCIUHZRHJDQVP3IQSUNJFXG4ZOAC
JSUQLISL2P54R4AJLE4TDRZOXMSGK3SQJEQTOUD7BZZSC3JE35KQC
WR2LC73HN6Z56NSL37UUGUGEUL5SF7MN344DHT4X5NPN4YZ4RQMQC
F7EHBV5ZMTWLG625Z3NEVDONESXOUZSBZFTDN2GADKLSQJZP72DAC
Z6JH7HGOELY6KHQX4DOHLU7Q7NAVO4YK7ZU3FRAABFMJEMESCKRQC
3PIOBGINNZSES3CV4FPGKCPQOSO2DYFKRUIVRLE62L2RGM3D3T2QC
let plus_emoji = "➕".parse::<ReactionType>().unwrap();
answer.react(ctx, plus_emoji.clone()).await?;
let more = answer
.await_reaction(ctx)
.timeout(Duration::from_secs(60 * 10))
.filter(move |reaction| reaction.emoji == plus_emoji)
.await;
if more.is_none() {
break;
}
}
let plus_emoji = "➕".parse::<ReactionType>().unwrap();
answer.react(ctx, plus_emoji.clone()).await?;
let more = answer
.await_reaction(ctx)
.timeout(Duration::from_secs(60 * 10))
.filter(move |reaction| reaction.emoji == plus_emoji)
.await;
if more.is_none() {
break;
}
}
let plus_emoji = "➕".parse::<ReactionType>().unwrap();
answer.react(ctx, plus_emoji.clone()).await?;
let more = answer
.await_reaction(ctx)
.timeout(Duration::from_secs(60 * 10))
.filter(move |reaction| reaction.emoji == plus_emoji)
.await;
if more.is_none() {
break;
}
}
let plus_emoji = "➕".parse::<ReactionType>().unwrap();
answer.react(ctx, plus_emoji.clone()).await?;
let more = answer
.await_reaction(ctx)
.timeout(Duration::from_secs(60 * 10))
.filter(move |reaction| reaction.emoji == plus_emoji)
.await;
if more.is_none() {
break;
}
}
/// You can execute what you want in the block, but it should return a `serenity::model::channel::Message`.
/// Then an emoji will be sent under the message, and while someone click on this emoji the block
/// will be repeated.
/// It also needs to get a `serenity::prelude::Context`.
/// Here is an example with the command fox:
/// ```no_run
/// #[command]
/// pub async fn fox(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
/// crate::repeat_message!(ctx, {
/// let url = fetch_random_fox_url().await?;
///
/// msg.channel_id
/// .send_files(&ctx, vec![url.as_str()], |m| m.content(&msg.author))
/// .await?
/// });
///
/// Ok(())
/// }
/// ```
#[macro_export]
macro_rules! repeat_message {
($ctx:ident, $code:block) => {
loop {
use serenity::model::channel::ReactionType;
let plus_emoji = "➕".parse::<ReactionType>().unwrap();
let answer = $code;
answer.react($ctx, plus_emoji.clone()).await?;
let more = answer
.await_reaction($ctx)
.timeout(std::time::Duration::from_secs(60 * 10))
.filter(move |reaction| reaction.emoji == plus_emoji)
.await;