Update rand version
This commit is contained in:
parent
3c667045cb
commit
f203de98b2
571
Cargo.lock
generated
571
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@ name = "shibe-bot"
|
|||||||
description = "A Discord bot written in Rust, using Poise."
|
description = "A Discord bot written in Rust, using Poise."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ log = "0.4.25"
|
|||||||
poise = "0.6.1"
|
poise = "0.6.1"
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
tokio = { version = "1.42", features = ["macros", "rt-multi-thread"] }
|
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 = { version = "1.0.219", features = ["serde_derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
roux = "2.2.13"
|
roux = "2.2.13"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Shibe Bot 1.0.1
|
# Shibe Bot 1.0.2
|
||||||
|
|
||||||
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
||||||
[](LICENSE.txt)
|
[](LICENSE.txt)
|
||||||
|
@ -48,6 +48,7 @@ pub async fn update(
|
|||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
#[description = "Whether to skip the update check"] override_check: bool,
|
#[description = "Whether to skip the update check"] override_check: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
ctx.defer().await?;
|
||||||
// Check if the current commit hash is different from HEAD
|
// Check if the current commit hash is different from HEAD
|
||||||
let head: octocrab::models::repos::Ref = octocrab::instance()
|
let head: octocrab::models::repos::Ref = octocrab::instance()
|
||||||
.get(
|
.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 mut dest = std::fs::File::create_new(tempdir.path().join("artifact.zip"))?;
|
||||||
let content = response.as_bytes();
|
let content = response.as_bytes();
|
||||||
dest.write_all(&content)?;
|
dest.write_all(content)?;
|
||||||
trace!("Downloaded latest build artifact successfully");
|
trace!("Downloaded latest build artifact successfully");
|
||||||
|
|
||||||
let mut archive = zip::ZipArchive::new(dest)?;
|
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 mut command = std::process::Command::new("systemctl");
|
||||||
|
|
||||||
let command = command
|
let command = command.arg("--user").arg("restart").arg("shibe-bot");
|
||||||
.arg("--user")
|
|
||||||
.arg("restart")
|
|
||||||
.arg("shibe-bot");
|
|
||||||
|
|
||||||
Err(Box::new(command.exec()))
|
Err(Box::new(command.exec()))
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ use crate::Context;
|
|||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
use poise::serenity_prelude as serenity;
|
use poise::serenity_prelude as serenity;
|
||||||
|
use rand::seq::IndexedRandom;
|
||||||
use rand::prelude::SliceRandom;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use roux::util::{FeedOption, TimePeriod};
|
use roux::util::{FeedOption, TimePeriod};
|
||||||
@ -30,8 +29,8 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
"bwrrrr,,,",
|
"bwrrrr,,,",
|
||||||
];
|
];
|
||||||
let response = {
|
let response = {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
if rng.gen_bool(0.05) {
|
if rng.random_bool(0.05) {
|
||||||
"woof"
|
"woof"
|
||||||
// Will never return None. The source is statically defined.
|
// Will never return None. The source is statically defined.
|
||||||
// We know it will always have items in it.
|
// We know it will always have items in it.
|
||||||
@ -122,7 +121,7 @@ pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
"Very doubtful",
|
"Very doubtful",
|
||||||
];
|
];
|
||||||
let response = {
|
let response = {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
responses
|
responses
|
||||||
.choose(&mut rng)
|
.choose(&mut rng)
|
||||||
.ok_or("Response array is empty".to_string())
|
.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 options = FeedOption::new().period(TimePeriod::ThisYear);
|
||||||
let hot = subreddit.hot(50, Some(options)).await?;
|
let hot = subreddit.hot(50, Some(options)).await?;
|
||||||
let chosen_post = {
|
let chosen_post = {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
hot.data
|
hot.data
|
||||||
.children
|
.children
|
||||||
.choose(&mut rng)
|
.choose(&mut rng)
|
||||||
|
@ -62,8 +62,8 @@ pub async fn dice(
|
|||||||
#[description = "The amount of sides on the dice"] sides: u32,
|
#[description = "The amount of sides on the dice"] sides: u32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let answer: u32 = {
|
let answer: u32 = {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
rng.gen_range(1..=sides)
|
rng.random_range(1..=sides)
|
||||||
};
|
};
|
||||||
let response = match sides {
|
let response = match sides {
|
||||||
0 | 1 => {
|
0 | 1 => {
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -1,5 +1,7 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
|
||||||
// For secure credential handling
|
// For secure credential handling
|
||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
|
|
||||||
@ -47,10 +49,10 @@ async fn main() {
|
|||||||
// Initialize logging
|
// Initialize logging
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
info!("Initialized logger successfully");
|
info!("Initialized logger successfully");
|
||||||
info!(
|
match env::current_exe() {
|
||||||
"Current executable path: {}",
|
Ok(exe) => info!("Got current exe successfully: {}", exe.display()),
|
||||||
std::env::current_exe().unwrap().display()
|
Err(err) => error!("Failed to get exe: {}", err),
|
||||||
);
|
}
|
||||||
// Get secure env vars from .env file
|
// Get secure env vars from .env file
|
||||||
match dotenv() {
|
match dotenv() {
|
||||||
Ok(_) => info!("Loaded env vars from .env successfully"),
|
Ok(_) => info!("Loaded env vars from .env successfully"),
|
||||||
|
Loading…
Reference in New Issue
Block a user