Update rand version

This commit is contained in:
August 2025-03-24 10:43:05 -04:00
parent 3c667045cb
commit f203de98b2
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
7 changed files with 334 additions and 276 deletions

571
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ name = "shibe-bot"
description = "A Discord bot written in Rust, using Poise."
license = "MIT"
readme = "README.md"
version = "1.0.1"
version = "1.0.2"
edition = "2021"
build = "build.rs"
@ -18,7 +18,7 @@ log = "0.4.25"
poise = "0.6.1"
pretty_env_logger = "0.5.0"
tokio = { version = "1.42", features = ["macros", "rt-multi-thread"] }
rand = "0.8.5"
rand = "0.9.0"
serde = { version = "1.0.219", features = ["serde_derive"] }
serde_json = "1.0.140"
roux = "2.2.13"

View File

@ -1,4 +1,4 @@
# Shibe Bot 1.0.1
# Shibe Bot 1.0.2
[![Rust](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml/badge.svg)](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
[![GitHub License](https://img.shields.io/github/license/shibedrill/shibe-bot)](LICENSE.txt)

View File

@ -48,6 +48,7 @@ pub async fn update(
ctx: Context<'_>,
#[description = "Whether to skip the update check"] override_check: bool,
) -> Result<(), Error> {
ctx.defer().await?;
// Check if the current commit hash is different from HEAD
let head: octocrab::models::repos::Ref = octocrab::instance()
.get(
@ -128,7 +129,7 @@ fn self_update() -> Result<Infallible, Error> {
let mut dest = std::fs::File::create_new(tempdir.path().join("artifact.zip"))?;
let content = response.as_bytes();
dest.write_all(&content)?;
dest.write_all(content)?;
trace!("Downloaded latest build artifact successfully");
let mut archive = zip::ZipArchive::new(dest)?;
@ -164,10 +165,7 @@ fn self_update() -> Result<Infallible, Error> {
let mut command = std::process::Command::new("systemctl");
let command = command
.arg("--user")
.arg("restart")
.arg("shibe-bot");
let command = command.arg("--user").arg("restart").arg("shibe-bot");
Err(Box::new(command.exec()))
}

View File

@ -2,8 +2,7 @@ use crate::Context;
use crate::Error;
use poise::serenity_prelude as serenity;
use rand::prelude::SliceRandom;
use rand::seq::IndexedRandom;
use rand::Rng;
use roux::util::{FeedOption, TimePeriod};
@ -30,8 +29,8 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
"bwrrrr,,,",
];
let response = {
let mut rng = rand::thread_rng();
if rng.gen_bool(0.05) {
let mut rng = rand::rng();
if rng.random_bool(0.05) {
"woof"
// Will never return None. The source is statically defined.
// We know it will always have items in it.
@ -122,7 +121,7 @@ pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> {
"Very doubtful",
];
let response = {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
responses
.choose(&mut rng)
.ok_or("Response array is empty".to_string())
@ -164,7 +163,7 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> {
let options = FeedOption::new().period(TimePeriod::ThisYear);
let hot = subreddit.hot(50, Some(options)).await?;
let chosen_post = {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
hot.data
.children
.choose(&mut rng)

View File

@ -62,8 +62,8 @@ pub async fn dice(
#[description = "The amount of sides on the dice"] sides: u32,
) -> Result<(), Error> {
let answer: u32 = {
let mut rng = rand::thread_rng();
rng.gen_range(1..=sides)
let mut rng = rand::rng();
rng.random_range(1..=sides)
};
let response = match sides {
0 | 1 => {

View File

@ -1,5 +1,7 @@
#![forbid(unsafe_code)]
use std::env;
// For secure credential handling
use dotenvy::dotenv;
@ -47,10 +49,10 @@ async fn main() {
// Initialize logging
pretty_env_logger::init();
info!("Initialized logger successfully");
info!(
"Current executable path: {}",
std::env::current_exe().unwrap().display()
);
match env::current_exe() {
Ok(exe) => info!("Got current exe successfully: {}", exe.display()),
Err(err) => error!("Failed to get exe: {}", err),
}
// Get secure env vars from .env file
match dotenv() {
Ok(_) => info!("Loaded env vars from .env successfully"),