minor fixes

This commit is contained in:
shibedrill 2024-05-16 17:22:29 -04:00
parent 2e8a833909
commit bbca218708
5 changed files with 18 additions and 14 deletions

2
Cargo.lock generated
View File

@ -1490,7 +1490,7 @@ dependencies = [
[[package]]
name = "shibe-bot"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"dotenv",
"log",

View File

@ -1,6 +1,6 @@
[package]
name = "shibe-bot"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -24,14 +24,18 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
"IM GONNA MROWWWWW!!11!11!",
"meow meow bitchass",
"mrrghh???",
"meow meow meow meow meow",
"mrow,,,,,",
"meow??",
"bwrrrr,,,",
];
let response = {
let mut rng = rand::thread_rng();
match rng.gen_bool(0.05) {
true => "woof",
// Will never return None. The source is staticaly defined.
// Will never return None. The source is statically defined.
// We know it will always have items in it.
false => meows.choose(&mut rng).unwrap(),
false => meows.choose(&mut rng).expect("`meows` array is empty"),
}
};
ctx.say(response).await?;
@ -92,7 +96,7 @@ pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> {
];
let response = {
let mut rng = rand::thread_rng();
responses.choose(&mut rng).unwrap()
responses.choose(&mut rng).expect("`responses` array is empty")
};
ctx.say(format!("Magic 8-ball says: '{}'", *response))
.await?;
@ -126,7 +130,7 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> {
let hot = subreddit.hot(50, Some(options)).await?;
let chosen_post = {
let mut rng = rand::thread_rng();
hot.data.children.choose(&mut rng).unwrap()
hot.data.children.choose(&mut rng).expect("Hot posts does not have any items")
};
ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink))
.await?;

View File

@ -39,8 +39,8 @@ pub async fn age(
pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
ctx.say(format!(
"Shibe Bot v{} was created by Shibe Drill (@shibedrill) using Rust and \
Poise.\nVisit her website: <https://riverdev.carrd.co>\nCheck out her \
Github: <https://github.com/shibedrill/shibe-bot>\n\
Poise.\nWebsite: <https://riverdev.carrd.co>\n\
Source code: <https://github.com/shibedrill/shibe-bot>\n\
Poise: <https://docs.rs/poise/latest/poise/>\n\
Rust: <https://www.rust-lang.org/>",
env!("CARGO_PKG_VERSION")
@ -59,7 +59,7 @@ pub async fn add_channel(
let config = &mut ctx.data().config_manager.lock().await;
let channel_id = { u64::from(channel.id()) };
config.channels.push(channel);
config.store().unwrap();
config.store().expect("Unable to store config");
ctx.say(format!(
"Successfully added <#{}> to the channel registry.",
channel_id
@ -79,7 +79,7 @@ pub async fn remove_channel(
let config = &mut ctx.data().config_manager.lock().await;
let channel_id = { u64::from(channel.id()) };
config.channels.retain(|c| c.id() != channel.id());
config.store().unwrap();
config.store().expect("Unable to store config");
ctx.say(format!(
"Successfully removed <#{}> from the channel registry.",
channel_id

View File

@ -125,7 +125,7 @@ async fn main() {
let mut client = serenity::ClientBuilder::new(token, intents)
.framework(framework)
.await
.unwrap();
.expect("Unable to build client");
info!("Built client successfully");
// List the owner
@ -135,14 +135,14 @@ async fn main() {
.http
.get_current_application_info()
.await
.unwrap()
.expect("Could not get current application info")
.owner
.unwrap()
.expect("Could not get owner info")
.name
);
// Finally start everything. Nothing after this should be reachable normally.
info!("Starting client");
client.start().await.unwrap();
client.start().await.expect("Could not start client");
info!("All tasks finished, shutting down");
}