mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 12:26:10 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f1b52d2be2
|
|||
|
e77818e09b
|
|||
|
5a026afc52
|
|||
|
8a0d08de4e
|
|||
|
f224ccfbdf
|
|||
|
d0af34833b
|
9
.gitmodules
vendored
Normal file
9
.gitmodules
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[submodule "libs/songbird"]
|
||||||
|
path = libs/songbird
|
||||||
|
url = git@github.com:eRgo35/songbird.git
|
||||||
|
[submodule "libs/serenity"]
|
||||||
|
path = libs/serenity
|
||||||
|
url = git@github.com:eRgo35/serenity.git
|
||||||
|
[submodule "libs/poise"]
|
||||||
|
path = libs/poise
|
||||||
|
url = git@github.com:eRgo35/poise.git
|
||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -1349,12 +1349,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lyra"
|
name = "lyra"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"fancy-regex",
|
"fancy-regex",
|
||||||
"json",
|
"json",
|
||||||
"lib-spotify-parser",
|
"lib-spotify-parser",
|
||||||
|
"once_cell",
|
||||||
"openssl",
|
"openssl",
|
||||||
"owoify",
|
"owoify",
|
||||||
"poise",
|
"poise",
|
||||||
@@ -2719,8 +2720,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serenity-voice-model"
|
name = "serenity-voice-model"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/serenity-rs/serenity?branch=current#658b6a7261fbde7cf59f84613f870ef7a48735c6"
|
||||||
checksum = "593682f6155d07c8b331b3d1060f5aab7e6796caca9f2f66bd9e6855c880e06b"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
|||||||
23
Cargo.toml
23
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lyra"
|
name = "lyra"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
authors = ["Michał Czyż <mike@c2yz.com>"]
|
authors = ["Michał Czyż <mike@c2yz.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A featureful Discord bot written in Rust."
|
description = "A featureful Discord bot written in Rust."
|
||||||
@@ -10,27 +10,31 @@ homepage = "https://lyra.c2yz.com"
|
|||||||
license-file = "LICENSE.md"
|
license-file = "LICENSE.md"
|
||||||
keywords = ["discord", "bot", "rust", "music", "featureful"]
|
keywords = ["discord", "bot", "rust", "music", "featureful"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lib-spotify-parser = { path = "libs/spotify-parser" }
|
lib-spotify-parser = { path = "./libs/spotify-parser" }
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
fancy-regex = "0.13.0"
|
fancy-regex = "0.13.0"
|
||||||
json = "0.12.4"
|
json = "0.12.4"
|
||||||
openssl = { version = "0.10.66", features = ["vendored"] }
|
openssl = { version = "0.10.66", features = ["vendored"] }
|
||||||
owoify = "0.1.5"
|
owoify = "0.1.5"
|
||||||
poise = "0.6.1"
|
poise = { default-features = true, version = "0.6.1" }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
regex = "1.10.6"
|
regex = "1.10.6"
|
||||||
reqwest = { version = "0.11.27", features = ["json"] }
|
reqwest = { version = "0.11.27", features = ["json"] }
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
serde_json = "1.0.122"
|
serde_json = "1.0.122"
|
||||||
serenity = { version = "0.12.2", features = [
|
songbird = { version = "0.4.3", default-features = true, features = [
|
||||||
|
"builtin-queue",
|
||||||
|
] }
|
||||||
|
serenity = { default-features = true, features = [
|
||||||
"cache",
|
"cache",
|
||||||
"framework",
|
"framework",
|
||||||
"standard_framework",
|
"standard_framework",
|
||||||
"voice",
|
"voice",
|
||||||
] }
|
"http",
|
||||||
songbird = { version = "0.4.3", features = ["builtin-queue", "serenity"] }
|
"rustls_backend",
|
||||||
|
], version = "0.12" }
|
||||||
|
|
||||||
symphonia = { version = "0.5.4", features = [
|
symphonia = { version = "0.5.4", features = [
|
||||||
"aac",
|
"aac",
|
||||||
"adpcm",
|
"adpcm",
|
||||||
@@ -44,3 +48,8 @@ tracing = "0.1.40"
|
|||||||
tracing-futures = "0.2.5"
|
tracing-futures = "0.2.5"
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
url = "2.5.2"
|
url = "2.5.2"
|
||||||
|
once_cell = "1.19.0"
|
||||||
|
|
||||||
|
[patch.crates-io.serenity-voice-model]
|
||||||
|
git = "https://github.com/serenity-rs/serenity"
|
||||||
|
branch = "current"
|
||||||
|
|||||||
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/poise
Submodule
1
libs/poise
Submodule
Submodule libs/poise added at 575025909b
1
libs/serenity
Submodule
1
libs/serenity
Submodule
Submodule libs/serenity added at 658b6a7261
1
libs/songbird
Submodule
1
libs/songbird
Submodule
Submodule libs/songbird added at 2d7dc29fd6
@@ -1,11 +1,9 @@
|
|||||||
use crate::{Context, Error};
|
use crate::{Context, Error};
|
||||||
|
|
||||||
use poise::serenity_prelude::CreateEmbed;
|
use poise::serenity_prelude::{
|
||||||
use poise::CreateReply;
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
use serenity::{
|
|
||||||
builder::{CreateEmbedAuthor, CreateEmbedFooter},
|
|
||||||
model::{Colour, Timestamp},
|
|
||||||
};
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> {
|
pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> {
|
||||||
ctx.send(
|
ctx.send(
|
||||||
@@ -25,7 +23,7 @@ pub async fn error_embed(ctx: Context<'_>, msg: &str) -> Result<CreateEmbed, Err
|
|||||||
.author(
|
.author(
|
||||||
CreateEmbedAuthor::new("Something went wrong!").icon_url(ctx.author().clone().face()),
|
CreateEmbedAuthor::new("Something went wrong!").icon_url(ctx.author().clone().face()),
|
||||||
)
|
)
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title("Oopsie, Doopsie!")
|
.title("Oopsie, Doopsie!")
|
||||||
.description(msg)
|
.description(msg)
|
||||||
.timestamp(Timestamp::now())
|
.timestamp(Timestamp::now())
|
||||||
@@ -45,7 +43,7 @@ pub async fn embed(
|
|||||||
) -> Result<CreateEmbed, Error> {
|
) -> Result<CreateEmbed, Error> {
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new(author).icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new(author).icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title)
|
.title(title)
|
||||||
.description(description)
|
.description(description)
|
||||||
.timestamp(Timestamp::now())
|
.timestamp(Timestamp::now())
|
||||||
|
|||||||
@@ -3,13 +3,11 @@ use crate::{commands::embeds::error_embed, Context, Error};
|
|||||||
|
|
||||||
use fancy_regex::Regex;
|
use fancy_regex::Regex;
|
||||||
use lib_spotify_parser;
|
use lib_spotify_parser;
|
||||||
use poise::serenity_prelude::model::Timestamp;
|
use poise::serenity_prelude::{
|
||||||
use poise::serenity_prelude::Colour;
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
use poise::serenity_prelude::CreateEmbed;
|
};
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
use regex::Regex as Regex_Classic;
|
use regex::Regex as Regex_Classic;
|
||||||
use serenity::builder::CreateEmbedAuthor;
|
|
||||||
use serenity::builder::CreateEmbedFooter;
|
|
||||||
use songbird::events::TrackEvent;
|
use songbird::events::TrackEvent;
|
||||||
use songbird::input::AuxMetadata;
|
use songbird::input::AuxMetadata;
|
||||||
use songbird::input::{Compose, YoutubeDl};
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
@@ -212,7 +210,7 @@ async fn generate_embed(
|
|||||||
|
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new("Track enqueued").icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new("Track enqueued").icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title.unwrap())
|
.title(title.unwrap())
|
||||||
.url(source_url.unwrap())
|
.url(source_url.unwrap())
|
||||||
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
@@ -260,7 +258,7 @@ async fn generate_playlist_embed(
|
|||||||
|
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new("Playlist enqueued").icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new("Playlist enqueued").icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title.as_ref().unwrap())
|
.title(title.as_ref().unwrap())
|
||||||
.url(source_url.as_ref().unwrap())
|
.url(source_url.as_ref().unwrap())
|
||||||
.thumbnail(
|
.thumbnail(
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use crate::commands::music::metadata::Metadata;
|
use crate::commands::music::metadata::Metadata;
|
||||||
use crate::{commands::embeds::error_embed, Context, Error};
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
use poise::serenity_prelude::CreateEmbed;
|
use poise::serenity_prelude::{
|
||||||
use poise::CreateReply;
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
use serenity::{
|
|
||||||
builder::{CreateEmbedAuthor, CreateEmbedFooter},
|
|
||||||
model::{Colour, Timestamp},
|
|
||||||
};
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
use songbird::input::AuxMetadata;
|
use songbird::input::AuxMetadata;
|
||||||
|
|
||||||
const QUEUE_DISPLAY_LENGTH: usize = 10;
|
const QUEUE_DISPLAY_LENGTH: usize = 10;
|
||||||
@@ -80,7 +78,7 @@ async fn embed(ctx: Context<'_>, queue: String) -> Result<CreateEmbed, Error> {
|
|||||||
|
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new("Queue").icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new("Queue").icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title)
|
.title(title)
|
||||||
.description(queue)
|
.description(queue)
|
||||||
.timestamp(timestamp)
|
.timestamp(timestamp)
|
||||||
|
|||||||
@@ -5,21 +5,15 @@ use crate::{
|
|||||||
commands::embeds::{embed, error_embed},
|
commands::embeds::{embed, error_embed},
|
||||||
Context, Error,
|
Context, Error,
|
||||||
};
|
};
|
||||||
use poise::CreateReply;
|
use poise::serenity_prelude::{
|
||||||
use serenity::{
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
builder::{CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter},
|
|
||||||
model::{Colour, Timestamp},
|
|
||||||
};
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
use songbird::{input::AuxMetadata, tracks::TrackHandle};
|
use songbird::{input::AuxMetadata, tracks::TrackHandle};
|
||||||
|
|
||||||
/// Skips the currently playing song; \
|
/// Skips the currently playing song; \
|
||||||
/// aliases: skip, :skipper:
|
/// aliases: skip, :skipper:
|
||||||
#[poise::command(
|
#[poise::command(prefix_command, slash_command, aliases("skipper:"), category = "Music")]
|
||||||
prefix_command,
|
|
||||||
slash_command,
|
|
||||||
aliases("skipper:"),
|
|
||||||
category = "Music"
|
|
||||||
)]
|
|
||||||
pub async fn skip(ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn skip(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
let guild_id = ctx.guild_id().unwrap();
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
@@ -88,7 +82,7 @@ async fn generate_embed(
|
|||||||
|
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new("Skipped!").icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new("Skipped!").icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title.as_ref().unwrap())
|
.title(title.as_ref().unwrap())
|
||||||
.url(source_url.as_ref().unwrap())
|
.url(source_url.as_ref().unwrap())
|
||||||
.thumbnail(
|
.thumbnail(
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use crate::{commands::embeds::error_embed, Context, Error};
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
|
|
||||||
use poise::serenity_prelude::model::Timestamp;
|
use poise::serenity_prelude::{
|
||||||
use poise::serenity_prelude::Colour;
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
use poise::serenity_prelude::CreateEmbed;
|
};
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
use serenity::builder::CreateEmbedAuthor;
|
|
||||||
use serenity::builder::CreateEmbedFooter;
|
|
||||||
use songbird::events::TrackEvent;
|
use songbird::events::TrackEvent;
|
||||||
use songbird::input::AuxMetadata;
|
use songbird::input::AuxMetadata;
|
||||||
use songbird::input::{Compose, YoutubeDl};
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
@@ -91,7 +89,7 @@ async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed,
|
|||||||
|
|
||||||
let embed = CreateEmbed::default()
|
let embed = CreateEmbed::default()
|
||||||
.author(CreateEmbedAuthor::new("Playing an effect!").icon_url(ctx.author().clone().face()))
|
.author(CreateEmbedAuthor::new("Playing an effect!").icon_url(ctx.author().clone().face()))
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title.unwrap())
|
.title(title.unwrap())
|
||||||
.url(source_url.unwrap())
|
.url(source_url.unwrap())
|
||||||
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use crate::{commands::embeds::error_embed, Context, Error};
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
|
|
||||||
use poise::serenity_prelude::model::Timestamp;
|
use poise::serenity_prelude::{
|
||||||
use poise::serenity_prelude::Colour;
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
use poise::serenity_prelude::CreateEmbed;
|
};
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
use serenity::builder::CreateEmbedAuthor;
|
|
||||||
use serenity::builder::CreateEmbedFooter;
|
|
||||||
use songbird::events::TrackEvent;
|
use songbird::events::TrackEvent;
|
||||||
use songbird::input::AuxMetadata;
|
use songbird::input::AuxMetadata;
|
||||||
use songbird::input::{Compose, YoutubeDl};
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
@@ -100,7 +98,7 @@ async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed,
|
|||||||
.author(
|
.author(
|
||||||
CreateEmbedAuthor::new("Audio output hijacked!").icon_url(ctx.author().clone().face()),
|
CreateEmbedAuthor::new("Audio output hijacked!").icon_url(ctx.author().clone().face()),
|
||||||
)
|
)
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title(title.unwrap())
|
.title(title.unwrap())
|
||||||
.url(source_url.unwrap())
|
.url(source_url.unwrap())
|
||||||
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pub mod posix;
|
|||||||
pub mod qr;
|
pub mod qr;
|
||||||
pub mod register;
|
pub mod register;
|
||||||
pub mod taf;
|
pub mod taf;
|
||||||
// pub mod uptime;
|
pub mod uptime;
|
||||||
pub mod verse;
|
pub mod verse;
|
||||||
pub mod weather;
|
pub mod weather;
|
||||||
|
|
||||||
@@ -26,6 +26,6 @@ pub use posix::posix;
|
|||||||
pub use qr::qr;
|
pub use qr::qr;
|
||||||
pub use register::register;
|
pub use register::register;
|
||||||
pub use taf::taf;
|
pub use taf::taf;
|
||||||
// pub use uptime::uptime;
|
pub use uptime::uptime;
|
||||||
pub use verse::verse;
|
pub use verse::verse;
|
||||||
pub use weather::weather;
|
pub use weather::weather;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub async fn ai(
|
|||||||
response = rng.gen_range(0..iamsorry.len());
|
response = rng.gen_range(0..iamsorry.len());
|
||||||
};
|
};
|
||||||
|
|
||||||
sleep(Duration::from_secs(3));
|
sleep(Duration::from_secs(1));
|
||||||
|
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default().embed(
|
CreateReply::default().embed(
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use poise::CreateReply;
|
use poise::serenity_prelude::{
|
||||||
use serenity::{
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
builder::{CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter},
|
|
||||||
model::{Colour, Timestamp},
|
|
||||||
};
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
use crate::{Context, Error};
|
use crate::{Context, Error};
|
||||||
use url::form_urlencoded;
|
use url::form_urlencoded;
|
||||||
@@ -34,7 +33,7 @@ async fn generate_embed(ctx: Context<'_>, message: String) -> Result<CreateEmbed
|
|||||||
CreateEmbedAuthor::new("Your message as a QR Code!")
|
CreateEmbedAuthor::new("Your message as a QR Code!")
|
||||||
.icon_url(ctx.author().clone().face()),
|
.icon_url(ctx.author().clone().face()),
|
||||||
)
|
)
|
||||||
.colour(Colour::from_rgb(255, 58, 97))
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
.title("Your QR Code:")
|
.title("Your QR Code:")
|
||||||
.url(url.clone())
|
.url(url.clone())
|
||||||
.image(url)
|
.image(url)
|
||||||
|
|||||||
@@ -1,34 +1,47 @@
|
|||||||
|
use once_cell::sync::Lazy;
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::{commands::embeds::embed, Context, Error};
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
// Currently unable to get information on how long the thread was running.
|
pub static PROCESS_UPTIME: Lazy<Mutex<std::time::SystemTime>> =
|
||||||
const PROCESS_UPTIME: i64 = 1000;
|
Lazy::new(|| Mutex::new(std::time::SystemTime::now()));
|
||||||
|
|
||||||
/// Checks how long the bot has been running
|
/// Checks how long the bot has been running
|
||||||
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
let uptime = PROCESS_UPTIME;
|
let start = *PROCESS_UPTIME.lock().unwrap();
|
||||||
let days = uptime / (24 * 60 * 60);
|
let uptime = std::time::SystemTime::now().duration_since(start).unwrap();
|
||||||
let hours = (uptime % (24 * 60 * 60)) / 3600;
|
|
||||||
let minutes = (uptime % 60 * 60) / 60;
|
|
||||||
let seconds = uptime % 60;
|
|
||||||
|
|
||||||
ctx.send(
|
let (days, hours, minutes, seconds) = (
|
||||||
CreateReply::default().embed(
|
uptime.as_secs() / 86400,
|
||||||
embed(
|
(uptime.as_secs() / 3600) % 24,
|
||||||
ctx,
|
(uptime.as_secs() / 60) % 60,
|
||||||
"I have been up and awake for",
|
uptime.as_secs() % 60,
|
||||||
&format!("{} seconds", uptime),
|
);
|
||||||
&format!(
|
|
||||||
"{} days, {} hours, {} minutes and {} seconds",
|
let mut message = format!(
|
||||||
|
"I have been awake for {} days, {} hours, {} minutes and {} seconds!",
|
||||||
days, hours, minutes, seconds
|
days, hours, minutes, seconds
|
||||||
),
|
);
|
||||||
)
|
|
||||||
.await
|
if days != 0 {
|
||||||
.unwrap(),
|
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?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@@ -1,3 +1,4 @@
|
|||||||
|
use commands::tools::uptime::PROCESS_UPTIME;
|
||||||
use poise::serenity_prelude::{self as serenity, ActivityData};
|
use poise::serenity_prelude::{self as serenity, ActivityData};
|
||||||
use reqwest::Client as HttpClient;
|
use reqwest::Client as HttpClient;
|
||||||
use songbird::SerenityInit;
|
use songbird::SerenityInit;
|
||||||
@@ -37,6 +38,8 @@ async fn main() {
|
|||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
dotenv::dotenv().expect("Failed to load .env file.");
|
dotenv::dotenv().expect("Failed to load .env file.");
|
||||||
|
|
||||||
|
let _ = *PROCESS_UPTIME.lock().unwrap();
|
||||||
|
|
||||||
let token =
|
let token =
|
||||||
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
|
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
|
||||||
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
||||||
@@ -70,7 +73,7 @@ async fn main() {
|
|||||||
tools::qr(),
|
tools::qr(),
|
||||||
tools::register(),
|
tools::register(),
|
||||||
tools::taf(),
|
tools::taf(),
|
||||||
// tools::uptime(),
|
tools::uptime(),
|
||||||
tools::verse(),
|
tools::verse(),
|
||||||
tools::weather(),
|
tools::weather(),
|
||||||
];
|
];
|
||||||
@@ -78,7 +81,7 @@ async fn main() {
|
|||||||
let options = poise::FrameworkOptions {
|
let options = poise::FrameworkOptions {
|
||||||
commands,
|
commands,
|
||||||
prefix_options: poise::PrefixFrameworkOptions {
|
prefix_options: poise::PrefixFrameworkOptions {
|
||||||
prefix: Some(prefix.to_string().into()),
|
prefix: Some(prefix.to_string()),
|
||||||
edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan(
|
edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan(
|
||||||
Duration::from_secs(3600),
|
Duration::from_secs(3600),
|
||||||
))),
|
))),
|
||||||
@@ -123,7 +126,7 @@ async fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let framework = poise::Framework::builder()
|
let framework = poise::Framework::builder()
|
||||||
.setup(move |ctx, ready, _framework| {
|
.setup(move |ctx, ready, framework| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
info!(
|
info!(
|
||||||
"{} [{}] connected successfully!",
|
"{} [{}] connected successfully!",
|
||||||
@@ -131,6 +134,12 @@ async fn main() {
|
|||||||
);
|
);
|
||||||
ctx.set_activity(Some(ActivityData::listening(prefix + "help")));
|
ctx.set_activity(Some(ActivityData::listening(prefix + "help")));
|
||||||
// poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
// poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||||
|
poise::builtins::register_in_guild(
|
||||||
|
ctx,
|
||||||
|
&framework.options().commands,
|
||||||
|
512680330495524873.into(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(Data {})
|
Ok(Data {})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user