added challenge command (and maybe suspend the project)
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -743,9 +743,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
|
||||
checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
@@ -1121,6 +1121,7 @@ dependencies = [
|
||||
name = "singh3"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.8.4",
|
||||
"regex",
|
||||
"serenity",
|
||||
"tokio",
|
||||
|
@@ -8,10 +8,11 @@ edition = "2018"
|
||||
tracing = "0.1.22"
|
||||
regex = "1.5.4"
|
||||
tokio-postgres = "0.7.2"
|
||||
rand = "0.8.4"
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10.8"
|
||||
features = ["cache", "framework", "standard_framework", "rustls_backend", "unstable_discord_api"]
|
||||
features = ["cache", "framework", "standard_framework", "rustls_backend", "unstable_discord_api", "collector"]
|
||||
|
||||
[dependencies.tokio]
|
||||
version = "1.0"
|
||||
|
@@ -30,7 +30,7 @@
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rust-bin.nightly.latest.default
|
||||
];
|
||||
cargoSha256 = "sha256-qpmDIhgHcSoX/wIJlKNULxrEr+KOrCdXOi7HDuCdlFM=";
|
||||
cargoSha256 = "sha256-K+WHOEo6reNfcs7pOZZmHZfZl4pUqlykfTdqgSyVURU=";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
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