added /eight_ball command
This commit is contained in:
@@ -7,4 +7,5 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
poise = "0.6.1"
|
poise = "0.6.1"
|
||||||
|
rand = "0.9.0"
|
||||||
tokio = { version = "1.43.0", features = ["rt-multi-thread"] }
|
tokio = { version = "1.43.0", features = ["rt-multi-thread"] }
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
### Medium priority:
|
### Medium priority:
|
||||||
- [ ] JSON -> Rules list
|
- [ ] JSON -> Rules list
|
||||||
|
* Structure: /rules [rulename/index]
|
||||||
- [ ] Postfix calculator
|
- [ ] Postfix calculator
|
||||||
- [ ] Postfic generator
|
- [ ] Postfic generator
|
||||||
- [ ] JSON -> BPS class init
|
- [ ] JSON -> BPS class init
|
||||||
- [ ] BPS args -> JSON
|
- [ ] BPS args -> JSON
|
||||||
- [ ] Random tip (from ByteDice.net/data/loadingScreenTips.json)
|
- [ ] Random tip (from ByteDice.net/data/loadingScreenTips.json)
|
||||||
- [ ] A command that just sends my socials
|
- [ ] A command that just sends my socials
|
||||||
- [ ] Magic 8 ball
|
- [x] Magic 8 ball
|
||||||
|
|
||||||
### Low priority:
|
### Low priority:
|
||||||
- [ ] Particle of the week
|
- [ ] Particle of the week
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
Yes.
|
||||||
|
No.
|
||||||
|
Maybe.
|
||||||
|
Ask again later.
|
||||||
|
Cannot predict now.
|
||||||
|
Outlook not so good.
|
||||||
|
Signs point to yes.
|
||||||
|
Very doubtful.
|
||||||
|
Without a doubt.
|
||||||
|
Better not tell you now.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
42 (That’s the answer, right?)
|
||||||
|
Try turning it off and on again.
|
||||||
|
Error 404: Answer not found.
|
||||||
|
Consult your nearest wizard.
|
||||||
|
Ask your cat. They know everything.
|
||||||
|
The stars say yes, but the moon disagrees.
|
||||||
|
You don’t want to know… trust me.
|
||||||
|
Sure, but don’t quote me on that.
|
||||||
|
In an alternate universe, yes.
|
||||||
|
Why are you asking a stupid bot?
|
||||||
|
Only if you bring snacks.
|
||||||
|
Flip a coin; I’m on break.
|
||||||
|
The spirits are buffering... please wait.
|
||||||
|
You already know the answer.
|
||||||
+21
@@ -1,6 +1,7 @@
|
|||||||
use crate::{send_embed, send_msg, Context, EmbedOptions, Error};
|
use crate::{send_embed, send_msg, Context, EmbedOptions, Error};
|
||||||
|
|
||||||
use poise::serenity_prelude::{OnlineStatus, Timestamp};
|
use poise::serenity_prelude::{OnlineStatus, Timestamp};
|
||||||
|
use rand::{seq::IteratorRandom, Rng};
|
||||||
|
|
||||||
|
|
||||||
#[poise::command(slash_command, prefix_command)]
|
#[poise::command(slash_command, prefix_command)]
|
||||||
@@ -65,5 +66,25 @@ pub async fn embed(
|
|||||||
}
|
}
|
||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[poise::command(slash_command, prefix_command)]
|
||||||
|
pub async fn eight_ball(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Question to ask."] question: String
|
||||||
|
) -> Result<(), Error>
|
||||||
|
{
|
||||||
|
let is_quirky = rand::rng().random_bool(0.2);
|
||||||
|
let list = &ctx.data().ball_prompts[if is_quirky { 1 } else { 0 }];
|
||||||
|
let rand_item = list.iter().choose(&mut rand::rng());
|
||||||
|
|
||||||
|
send_msg(
|
||||||
|
ctx,
|
||||||
|
format!("Q: {}\nA: {}", question, rand_item.unwrap()),
|
||||||
|
true
|
||||||
|
).await?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
+5
-1
@@ -9,7 +9,7 @@ pub fn event_handler<'a>(
|
|||||||
ctx: &'a serenity::Context,
|
ctx: &'a serenity::Context,
|
||||||
event: &'a serenity::FullEvent,
|
event: &'a serenity::FullEvent,
|
||||||
_framework: poise::FrameworkContext<'a, Data, Error>,
|
_framework: poise::FrameworkContext<'a, Data, Error>,
|
||||||
_data: &'a Data,
|
data: &'a Data,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
|
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
if let serenity::FullEvent::Ready { data_about_bot } = event {
|
if let serenity::FullEvent::Ready { data_about_bot } = event {
|
||||||
@@ -19,6 +19,10 @@ pub fn event_handler<'a>(
|
|||||||
data_about_bot.user.id
|
data_about_bot.user.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if data.dev {
|
||||||
|
println!("----- DEV MODE ENABLED -----");
|
||||||
|
}
|
||||||
|
|
||||||
let file_text = std::fs::read_to_string("./data/status.txt").unwrap();
|
let file_text = std::fs::read_to_string("./data/status.txt").unwrap();
|
||||||
let custom_activity = ActivityData::custom(file_text);
|
let custom_activity = ActivityData::custom(file_text);
|
||||||
// TODO: make custom rich presence
|
// TODO: make custom rich presence
|
||||||
|
|||||||
+13
-3
@@ -7,7 +7,8 @@ use std::env;
|
|||||||
use poise::serenity_prelude::{self as serenity, Color, CreateEmbed, Timestamp};
|
use poise::serenity_prelude::{self as serenity, Color, CreateEmbed, Timestamp};
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
dev: bool
|
dev: bool,
|
||||||
|
ball_prompts: [Vec<String>; 2]
|
||||||
}
|
}
|
||||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||||
@@ -38,8 +39,16 @@ impl Default for EmbedOptions {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
|
let ball_classic_str = std::fs::read_to_string("./data/8-ball_classic.txt").unwrap();
|
||||||
|
let ball_quirk_str = std::fs::read_to_string("./data/8-ball_quirky.txt").unwrap();
|
||||||
|
|
||||||
|
let ball_classic: Vec<String> = ball_classic_str.lines().map(String::from).collect();
|
||||||
|
let ball_quirk: Vec<String> = ball_quirk_str .lines().map(String::from).collect();
|
||||||
|
|
||||||
let data = Data {
|
let data = Data {
|
||||||
dev: args.contains(&"--dev".to_string())
|
dev: args.contains(&"--dev".to_string()),
|
||||||
|
ball_prompts: [ball_classic, ball_quirk]
|
||||||
};
|
};
|
||||||
|
|
||||||
let token = std::env::var("ASSISTANT_TOKEN").expect("missing ASSISTANT_TOKEN env var");
|
let token = std::env::var("ASSISTANT_TOKEN").expect("missing ASSISTANT_TOKEN env var");
|
||||||
@@ -56,7 +65,8 @@ async fn main() {
|
|||||||
commands: vec![
|
commands: vec![
|
||||||
cmds::ping(),
|
cmds::ping(),
|
||||||
cmds::embed(),
|
cmds::embed(),
|
||||||
cmds::stop()
|
cmds::stop(),
|
||||||
|
cmds::eight_ball()
|
||||||
],
|
],
|
||||||
event_handler: events::event_handler,
|
event_handler: events::event_handler,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
Reference in New Issue
Block a user