added challenge command (and maybe suspend the project)
This commit is contained in:
65
src/commands/minigames.rs
Normal file
65
src/commands/minigames.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
use rand::random;
|
||||
use serenity::{
|
||||
framework::standard::{macros::command, CommandResult},
|
||||
model::prelude::*,
|
||||
prelude::*,
|
||||
};
|
||||
use std::time::Duration;
|
||||
#[command]
|
||||
pub async fn challenge(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
if msg.mentions.is_empty() {
|
||||
msg.reply(ctx, "mention to daal chutiye").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let challenge = msg
|
||||
.channel_id
|
||||
.say(
|
||||
ctx,
|
||||
format!(
|
||||
"{}, reply to this message to accept the challenge by {} in 60s [y/n]",
|
||||
msg.mentions[0].mention(),
|
||||
msg.author.mention()
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
if let Some(answer) = &msg.mentions[0]
|
||||
.await_reply(&ctx)
|
||||
.timeout(Duration::from_secs(60))
|
||||
.await
|
||||
{
|
||||
if ["yes", "y", "ha"].contains(&answer.content.to_lowercase().as_str()) {
|
||||
answer
|
||||
.reply(ctx, format!("Challenge accepted, {}", msg.author.mention()))
|
||||
.await?;
|
||||
challenge.delete(&ctx.http).await?;
|
||||
} else if ["no", "nahi", "n"].contains(&answer.content.to_lowercase().as_str()) {
|
||||
msg.reply(ctx, "Challenge not accepted").await?;
|
||||
challenge.delete(&ctx.http).await?;
|
||||
return Ok(());
|
||||
} else {
|
||||
answer
|
||||
.reply(
|
||||
ctx,
|
||||
"Please only answer in no/nahi/n or yes/ha/y\ndeleting challenge ...",
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
msg.reply(ctx, "Challenge not accepted in 60s").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let won = random();
|
||||
let winner = if won {
|
||||
msg.mentions[0].mention()
|
||||
} else {
|
||||
msg.author.mention()
|
||||
};
|
||||
let loser = if won {
|
||||
msg.author.mention()
|
||||
} else {
|
||||
msg.mentions[0].mention()
|
||||
};
|
||||
msg.reply(ctx, format!("{} won, {} ki ma ki chut", winner, loser))
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
@@ -1,2 +1,3 @@
|
||||
pub mod general;
|
||||
pub mod count;
|
||||
pub mod minigames;
|
||||
|
@@ -11,6 +11,7 @@ use tracing::error;
|
||||
pub struct ShardManagerContainer;
|
||||
use commands::general::*;
|
||||
use commands::count::*;
|
||||
use commands::minigames::*;
|
||||
use handler::Handler;
|
||||
|
||||
impl TypeMapKey for ShardManagerContainer {
|
||||
@@ -25,6 +26,10 @@ struct General;
|
||||
#[commands(kitna)]
|
||||
struct Count;
|
||||
|
||||
#[group]
|
||||
#[commands(challenge)]
|
||||
struct Minigames;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let token = env::var("DISCORD_TOKEN").expect("Token daal madarchod");
|
||||
@@ -44,7 +49,8 @@ async fn main() {
|
||||
let framework = StandardFramework::new()
|
||||
.configure(|c| c.owners(owners).prefix("xx"))
|
||||
.group(&GENERAL_GROUP)
|
||||
.group(&COUNT_GROUP);
|
||||
.group(&COUNT_GROUP)
|
||||
.group(&MINIGAMES_GROUP);
|
||||
|
||||
let mut client = Client::builder(&token)
|
||||
.framework(framework)
|
||||
|
Reference in New Issue
Block a user