mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 20:36:10 +01:00
Compare commits
3 Commits
0.9.0
...
8a0d08de4e
| Author | SHA1 | Date | |
|---|---|---|---|
|
8a0d08de4e
|
|||
|
f224ccfbdf
|
|||
|
d0af34833b
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "libs/songbird"]
|
||||
path = libs/songbird
|
||||
url = git@github.com:eRgo35/songbird.git
|
||||
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -1355,6 +1355,7 @@ dependencies = [
|
||||
"fancy-regex",
|
||||
"json",
|
||||
"lib-spotify-parser",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
"owoify",
|
||||
"poise",
|
||||
@@ -2828,8 +2829,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "songbird"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "338dd182f9f084f583c4c0db38588e28a34778ecec288208cf0b61c378ac90d1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"audiopus",
|
||||
|
||||
13
Cargo.toml
13
Cargo.toml
@@ -10,7 +10,6 @@ homepage = "https://lyra.c2yz.com"
|
||||
license-file = "LICENSE.md"
|
||||
keywords = ["discord", "bot", "rust", "music", "featureful"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
lib-spotify-parser = { path = "libs/spotify-parser" }
|
||||
dotenv = "0.15.0"
|
||||
@@ -24,13 +23,18 @@ regex = "1.10.6"
|
||||
reqwest = { version = "0.11.27", features = ["json"] }
|
||||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
serde_json = "1.0.122"
|
||||
serenity = { version = "0.12.2", features = [
|
||||
songbird = { path = "./libs/songbird", version = "0.4", default-features = true, features = [
|
||||
"builtin-queue",
|
||||
] }
|
||||
serenity = { features = [
|
||||
"cache",
|
||||
"framework",
|
||||
"standard_framework",
|
||||
"voice",
|
||||
] }
|
||||
songbird = { version = "0.4.3", features = ["builtin-queue", "serenity"] }
|
||||
"http",
|
||||
"rustls_backend",
|
||||
], version = "0.12" }
|
||||
|
||||
symphonia = { version = "0.5.4", features = [
|
||||
"aac",
|
||||
"adpcm",
|
||||
@@ -44,3 +48,4 @@ tracing = "0.1.40"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-subscriber = "0.3.18"
|
||||
url = "2.5.2"
|
||||
once_cell = "1.19.0"
|
||||
|
||||
BIN
assets/lyra-nightly.png
Normal file
BIN
assets/lyra-nightly.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 KiB |
1
libs/songbird
Submodule
1
libs/songbird
Submodule
Submodule libs/songbird added at 52ccf8b328
@@ -10,7 +10,7 @@ pub mod posix;
|
||||
pub mod qr;
|
||||
pub mod register;
|
||||
pub mod taf;
|
||||
// pub mod uptime;
|
||||
pub mod uptime;
|
||||
pub mod verse;
|
||||
pub mod weather;
|
||||
|
||||
@@ -26,6 +26,6 @@ pub use posix::posix;
|
||||
pub use qr::qr;
|
||||
pub use register::register;
|
||||
pub use taf::taf;
|
||||
// pub use uptime::uptime;
|
||||
pub use uptime::uptime;
|
||||
pub use verse::verse;
|
||||
pub use weather::weather;
|
||||
|
||||
@@ -35,7 +35,7 @@ pub async fn ai(
|
||||
response = rng.gen_range(0..iamsorry.len());
|
||||
};
|
||||
|
||||
sleep(Duration::from_secs(3));
|
||||
sleep(Duration::from_secs(1));
|
||||
|
||||
ctx.send(
|
||||
CreateReply::default().embed(
|
||||
|
||||
@@ -1,35 +1,48 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use poise::CreateReply;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::{commands::embeds::embed, Context, Error};
|
||||
|
||||
// Currently unable to get information on how long the thread was running.
|
||||
const PROCESS_UPTIME: i64 = 1000;
|
||||
pub static PROCESS_UPTIME: Lazy<Mutex<std::time::SystemTime>> =
|
||||
Lazy::new(|| Mutex::new(std::time::SystemTime::now()));
|
||||
|
||||
/// Checks how long the bot has been running
|
||||
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||
pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let uptime = PROCESS_UPTIME;
|
||||
let days = uptime / (24 * 60 * 60);
|
||||
let hours = (uptime % (24 * 60 * 60)) / 3600;
|
||||
let minutes = (uptime % 60 * 60) / 60;
|
||||
let seconds = uptime % 60;
|
||||
let start = PROCESS_UPTIME.lock().unwrap().clone();
|
||||
let uptime = std::time::SystemTime::now().duration_since(start).unwrap();
|
||||
|
||||
ctx.send(
|
||||
CreateReply::default().embed(
|
||||
embed(
|
||||
ctx,
|
||||
"I have been up and awake for",
|
||||
&format!("{} seconds", uptime),
|
||||
&format!(
|
||||
"{} days, {} hours, {} minutes and {} seconds",
|
||||
days, hours, minutes, seconds
|
||||
),
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
let (days, hours, minutes, seconds) = (
|
||||
uptime.as_secs() / 86400,
|
||||
(uptime.as_secs() / 3600) % 24,
|
||||
(uptime.as_secs() / 60) % 60,
|
||||
uptime.as_secs() % 60,
|
||||
);
|
||||
|
||||
let mut message = format!(
|
||||
"I have been awake for {} days, {} hours, {} minutes and {} seconds!",
|
||||
days, hours, minutes, seconds
|
||||
);
|
||||
|
||||
if days != 0 {
|
||||
message = format!("I have been awake for {} days!", days);
|
||||
}
|
||||
|
||||
if days == 0 && hours != 0 {
|
||||
message = format!("I have been awake for {} hours!", hours);
|
||||
}
|
||||
|
||||
if days == 0 && hours == 0 && minutes != 0 {
|
||||
message = format!("I have been awake for {} minutes!", minutes);
|
||||
}
|
||||
|
||||
if days == 0 && hours == 0 && minutes == 0 && seconds != 0 {
|
||||
message = format!("I have been awake for {} seconds!", seconds);
|
||||
}
|
||||
|
||||
ctx.send(CreateReply::default().embed(embed(ctx, "Uptime", "", &message).await.unwrap()))
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
13
src/main.rs
13
src/main.rs
@@ -1,3 +1,4 @@
|
||||
use commands::tools::uptime::PROCESS_UPTIME;
|
||||
use poise::serenity_prelude::{self as serenity, ActivityData};
|
||||
use reqwest::Client as HttpClient;
|
||||
use songbird::SerenityInit;
|
||||
@@ -37,6 +38,8 @@ async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
dotenv::dotenv().expect("Failed to load .env file.");
|
||||
|
||||
let _ = PROCESS_UPTIME.lock().unwrap().clone();
|
||||
|
||||
let token =
|
||||
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
|
||||
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
||||
@@ -70,7 +73,7 @@ async fn main() {
|
||||
tools::qr(),
|
||||
tools::register(),
|
||||
tools::taf(),
|
||||
// tools::uptime(),
|
||||
tools::uptime(),
|
||||
tools::verse(),
|
||||
tools::weather(),
|
||||
];
|
||||
@@ -123,7 +126,7 @@ async fn main() {
|
||||
};
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
.setup(move |ctx, ready, _framework| {
|
||||
.setup(move |ctx, ready, framework| {
|
||||
Box::pin(async move {
|
||||
info!(
|
||||
"{} [{}] connected successfully!",
|
||||
@@ -131,6 +134,12 @@ async fn main() {
|
||||
);
|
||||
ctx.set_activity(Some(ActivityData::listening(prefix + "help")));
|
||||
// poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
poise::builtins::register_in_guild(
|
||||
ctx,
|
||||
&framework.options().commands,
|
||||
512680330495524873.into(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Data {})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user