forked from natto1784/singh3
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]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
|
checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-utils"
|
name = "pin-utils"
|
||||||
@@ -1121,6 +1121,7 @@ dependencies = [
|
|||||||
name = "singh3"
|
name = "singh3"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"rand 0.8.4",
|
||||||
"regex",
|
"regex",
|
||||||
"serenity",
|
"serenity",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@@ -8,10 +8,11 @@ edition = "2018"
|
|||||||
tracing = "0.1.22"
|
tracing = "0.1.22"
|
||||||
regex = "1.5.4"
|
regex = "1.5.4"
|
||||||
tokio-postgres = "0.7.2"
|
tokio-postgres = "0.7.2"
|
||||||
|
rand = "0.8.4"
|
||||||
|
|
||||||
[dependencies.serenity]
|
[dependencies.serenity]
|
||||||
version = "0.10.8"
|
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]
|
[dependencies.tokio]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
rust-bin.nightly.latest.default
|
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 general;
|
||||||
pub mod count;
|
pub mod count;
|
||||||
|
pub mod minigames;
|
||||||
|
@@ -11,6 +11,7 @@ use tracing::error;
|
|||||||
pub struct ShardManagerContainer;
|
pub struct ShardManagerContainer;
|
||||||
use commands::general::*;
|
use commands::general::*;
|
||||||
use commands::count::*;
|
use commands::count::*;
|
||||||
|
use commands::minigames::*;
|
||||||
use handler::Handler;
|
use handler::Handler;
|
||||||
|
|
||||||
impl TypeMapKey for ShardManagerContainer {
|
impl TypeMapKey for ShardManagerContainer {
|
||||||
@@ -25,6 +26,10 @@ struct General;
|
|||||||
#[commands(kitna)]
|
#[commands(kitna)]
|
||||||
struct Count;
|
struct Count;
|
||||||
|
|
||||||
|
#[group]
|
||||||
|
#[commands(challenge)]
|
||||||
|
struct Minigames;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let token = env::var("DISCORD_TOKEN").expect("Token daal madarchod");
|
let token = env::var("DISCORD_TOKEN").expect("Token daal madarchod");
|
||||||
@@ -44,7 +49,8 @@ async fn main() {
|
|||||||
let framework = StandardFramework::new()
|
let framework = StandardFramework::new()
|
||||||
.configure(|c| c.owners(owners).prefix("xx"))
|
.configure(|c| c.owners(owners).prefix("xx"))
|
||||||
.group(&GENERAL_GROUP)
|
.group(&GENERAL_GROUP)
|
||||||
.group(&COUNT_GROUP);
|
.group(&COUNT_GROUP)
|
||||||
|
.group(&MINIGAMES_GROUP);
|
||||||
|
|
||||||
let mut client = Client::builder(&token)
|
let mut client = Client::builder(&token)
|
||||||
.framework(framework)
|
.framework(framework)
|
||||||
|
Reference in New Issue
Block a user