make pridemonth rng seeded
This makes sure the chosen VARIANT for a given day is the same, regardless of whether or not the bot restarts. A different seed it chosen each day and each year of pride month, which should lead to okay results spread wise.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use chrono::{Datelike, Utc};
|
use chrono::{Datelike, Utc};
|
||||||
use chrono_tz::Europe::Warsaw;
|
use chrono_tz::Europe::Warsaw;
|
||||||
use rand::seq::IndexedRandom;
|
use rand::{SeedableRng, seq::IndexedRandom};
|
||||||
use serenity::all::{Context, GuildId};
|
use serenity::all::{Context, GuildId};
|
||||||
use service::run_event_service;
|
use service::run_event_service;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
@@ -86,7 +86,9 @@ impl Event {
|
|||||||
format!("Gractwo{suffix}")
|
format!("Gractwo{suffix}")
|
||||||
}
|
}
|
||||||
E::PrideMonth => {
|
E::PrideMonth => {
|
||||||
let mut rng = rand::rng();
|
let now = Utc::now().with_timezone(&Warsaw);
|
||||||
|
let seed: u64 = (now.year() as u64) * 1000 + (now.day() as u64);
|
||||||
|
let mut rng = rand::rngs::SmallRng::seed_from_u64(seed);
|
||||||
const VARIANTS: &[&str] = &[
|
const VARIANTS: &[&str] = &[
|
||||||
"Miesiąc Dumy",
|
"Miesiąc Dumy",
|
||||||
"Pride Month",
|
"Pride Month",
|
||||||
|
|||||||
Reference in New Issue
Block a user