Add response to /random
This commit is contained in:
1 parent
bec92177cb
commit
605bc37db6
4 files changed
+11
-4
No files matched your search
@@ -78,9 +78,15 @@ pub async fn play_random(
|
||||
join_channel(ctx.serenity_context(), guild.clone(), channel).await;
|
||||
|
||||
let sounds = ctx.data().guild_sounds(guild.id, None).await?;
|
||||
if sounds.len() == 0 {
|
||||
ctx.say("No sounds in this server!").await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let ts = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
|
||||
println!("{}", ts.subsec_micros());
|
||||
|
||||
// This is far cheaper and easier than using an RNG. No reason to use a full RNG here
|
||||
// anyway.
|
||||
match sounds.get(ts.subsec_micros() as usize % sounds.len()) {
|
||||
@@ -97,6 +103,9 @@ pub async fn play_random(
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
ctx.say(format!("Playing {} (ID {})", sound.name, sound.id))
|
||||
.await?;
|
||||
}
|
||||
|
||||
None => {
|
||||
|
||||
Reference in new issue
Block a user