0.9.1 heartbeat no longer dropping

This commit is contained in:
2024-08-05 15:01:45 +02:00
parent 5a026afc52
commit e77818e09b
13 changed files with 92 additions and 69 deletions

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[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

60
Cargo.lock generated
View File

@@ -294,8 +294,6 @@ dependencies = [
[[package]]
name = "command_attr"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88da8d7e9fe6f30d8e3fcf72d0f84102b49de70fece952633e8439e89bdc7631"
dependencies = [
"proc-macro2",
"quote",
@@ -1349,7 +1347,7 @@ dependencies = [
[[package]]
name = "lyra"
version = "0.9.0"
version = "0.9.1"
dependencies = [
"dotenv",
"fancy-regex",
@@ -1364,7 +1362,7 @@ dependencies = [
"reqwest 0.11.27",
"serde",
"serde_json",
"serenity",
"serenity 0.12.2",
"songbird",
"symphonia",
"tokio",
@@ -1863,25 +1861,23 @@ dependencies = [
[[package]]
name = "poise"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1819d5a45e3590ef33754abce46432570c54a120798bdbf893112b4211fa09a6"
dependencies = [
"async-trait",
"derivative",
"futures-util",
"indexmap",
"parking_lot",
"poise_macros",
"regex",
"serenity",
"serenity 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio",
"tracing",
"trim-in-place",
]
[[package]]
name = "poise_macros"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fa2c123c961e78315cd3deac7663177f12be4460f5440dbf62a7ed37b1effea"
dependencies = [
"darling 0.20.10",
"proc-macro2",
@@ -2683,8 +2679,6 @@ dependencies = [
[[package]]
name = "serenity"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac"
dependencies = [
"arrayvec",
"async-trait",
@@ -2717,11 +2711,43 @@ dependencies = [
"uwl",
]
[[package]]
name = "serenity"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac"
dependencies = [
"arrayvec",
"async-trait",
"base64 0.22.1",
"bitflags 2.6.0",
"bytes",
"chrono",
"dashmap",
"flate2",
"futures",
"fxhash",
"mime_guess",
"parking_lot",
"percent-encoding",
"reqwest 0.11.27",
"secrecy",
"serde",
"serde_cow",
"serde_json",
"time",
"tokio",
"tokio-tungstenite 0.21.0",
"tracing",
"typemap_rev",
"typesize",
"url",
]
[[package]]
name = "serenity-voice-model"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "593682f6155d07c8b331b3d1060f5aab7e6796caca9f2f66bd9e6855c880e06b"
source = "git+https://github.com/serenity-rs/serenity?branch=current#658b6a7261fbde7cf59f84613f870ef7a48735c6"
dependencies = [
"bitflags 2.6.0",
"num-traits",
@@ -2852,7 +2878,7 @@ dependencies = [
"serde",
"serde-aux",
"serde_json",
"serenity",
"serenity 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serenity-voice-model",
"socket2",
"stream_lib",
@@ -3585,6 +3611,12 @@ dependencies = [
"strength_reduce",
]
[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"
[[package]]
name = "triomphe"
version = "0.1.13"

View File

@@ -1,6 +1,6 @@
[package]
name = "lyra"
version = "0.9.0"
version = "0.9.1"
authors = ["Michał Czyż <mike@c2yz.com>"]
edition = "2021"
description = "A featureful Discord bot written in Rust."
@@ -11,19 +11,19 @@ license-file = "LICENSE.md"
keywords = ["discord", "bot", "rust", "music", "featureful"]
[dependencies]
lib-spotify-parser = { path = "libs/spotify-parser" }
lib-spotify-parser = { path = "./libs/spotify-parser" }
dotenv = "0.15.0"
fancy-regex = "0.13.0"
json = "0.12.4"
openssl = { version = "0.10.66", features = ["vendored"] }
owoify = "0.1.5"
poise = "0.6.1"
poise = { path = "./libs/poise", default-features = true, version = "0.6.1" }
rand = "0.8.5"
regex = "1.10.6"
reqwest = { version = "0.11.27", features = ["json"] }
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.122"
songbird = { path = "./libs/songbird", version = "0.4", default-features = true, features = [
songbird = { path = "./libs/songbird", version = "0.4.3", default-features = true, features = [
"builtin-queue",
] }
serenity = { path = "./libs/serenity", default-features = true, features = [
@@ -49,3 +49,7 @@ tracing-futures = "0.2.5"
tracing-subscriber = "0.3.18"
url = "2.5.2"
once_cell = "1.19.0"
[patch.crates-io.serenity-voice-model]
git = "https://github.com/serenity-rs/serenity"
branch = "current"

1
libs/poise Submodule

Submodule libs/poise added at 575025909b

View File

@@ -1,11 +1,9 @@
use crate::{Context, Error};
use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
use serenity::{
builder::{CreateEmbedAuthor, CreateEmbedFooter},
model::{Colour, Timestamp},
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> {
ctx.send(
@@ -25,7 +23,7 @@ pub async fn error_embed(ctx: Context<'_>, msg: &str) -> Result<CreateEmbed, Err
.author(
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!")
.description(msg)
.timestamp(Timestamp::now())
@@ -45,7 +43,7 @@ pub async fn embed(
) -> Result<CreateEmbed, Error> {
let embed = CreateEmbed::default()
.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)
.description(description)
.timestamp(Timestamp::now())

View File

@@ -3,13 +3,11 @@ use crate::{commands::embeds::error_embed, Context, Error};
use fancy_regex::Regex;
use lib_spotify_parser;
use poise::serenity_prelude::model::Timestamp;
use poise::serenity_prelude::Colour;
use poise::serenity_prelude::CreateEmbed;
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use regex::Regex as Regex_Classic;
use serenity::builder::CreateEmbedAuthor;
use serenity::builder::CreateEmbedFooter;
use songbird::events::TrackEvent;
use songbird::input::AuxMetadata;
use songbird::input::{Compose, YoutubeDl};
@@ -212,7 +210,7 @@ async fn generate_embed(
let embed = CreateEmbed::default()
.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())
.url(source_url.unwrap())
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
@@ -260,7 +258,7 @@ async fn generate_playlist_embed(
let embed = CreateEmbed::default()
.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())
.url(source_url.as_ref().unwrap())
.thumbnail(

View File

@@ -2,12 +2,10 @@ use std::time::Duration;
use crate::commands::music::metadata::Metadata;
use crate::{commands::embeds::error_embed, Context, Error};
use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
use serenity::{
builder::{CreateEmbedAuthor, CreateEmbedFooter},
model::{Colour, Timestamp},
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use songbird::input::AuxMetadata;
const QUEUE_DISPLAY_LENGTH: usize = 10;
@@ -80,7 +78,7 @@ async fn embed(ctx: Context<'_>, queue: String) -> Result<CreateEmbed, Error> {
let embed = CreateEmbed::default()
.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)
.description(queue)
.timestamp(timestamp)

View File

@@ -5,21 +5,15 @@ use crate::{
commands::embeds::{embed, error_embed},
Context, Error,
};
use poise::CreateReply;
use serenity::{
builder::{CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter},
model::{Colour, Timestamp},
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use songbird::{input::AuxMetadata, tracks::TrackHandle};
/// Skips the currently playing song; \
/// aliases: skip, :skipper:
#[poise::command(
prefix_command,
slash_command,
aliases("skipper:"),
category = "Music"
)]
#[poise::command(prefix_command, slash_command, aliases("skipper:"), category = "Music")]
pub async fn skip(ctx: Context<'_>) -> Result<(), Error> {
let guild_id = ctx.guild_id().unwrap();
@@ -88,7 +82,7 @@ async fn generate_embed(
let embed = CreateEmbed::default()
.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())
.url(source_url.as_ref().unwrap())
.thumbnail(

View File

@@ -1,11 +1,9 @@
use crate::{commands::embeds::error_embed, Context, Error};
use poise::serenity_prelude::model::Timestamp;
use poise::serenity_prelude::Colour;
use poise::serenity_prelude::CreateEmbed;
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use serenity::builder::CreateEmbedAuthor;
use serenity::builder::CreateEmbedFooter;
use songbird::events::TrackEvent;
use songbird::input::AuxMetadata;
use songbird::input::{Compose, YoutubeDl};
@@ -91,7 +89,7 @@ async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed,
let embed = CreateEmbed::default()
.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())
.url(source_url.unwrap())
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))

View File

@@ -1,11 +1,9 @@
use crate::{commands::embeds::error_embed, Context, Error};
use poise::serenity_prelude::model::Timestamp;
use poise::serenity_prelude::Colour;
use poise::serenity_prelude::CreateEmbed;
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use serenity::builder::CreateEmbedAuthor;
use serenity::builder::CreateEmbedFooter;
use songbird::events::TrackEvent;
use songbird::input::AuxMetadata;
use songbird::input::{Compose, YoutubeDl};
@@ -100,7 +98,7 @@ async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed,
.author(
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())
.url(source_url.unwrap())
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))

View File

@@ -1,8 +1,7 @@
use poise::CreateReply;
use serenity::{
builder::{CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter},
model::{Colour, Timestamp},
use poise::serenity_prelude::{
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
};
use poise::CreateReply;
use crate::{Context, Error};
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!")
.icon_url(ctx.author().clone().face()),
)
.colour(Colour::from_rgb(255, 58, 97))
.colour(Color::from_rgb(255, 58, 97))
.title("Your QR Code:")
.url(url.clone())
.image(url)

View File

@@ -10,7 +10,7 @@ pub static PROCESS_UPTIME: Lazy<Mutex<std::time::SystemTime>> =
/// 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 start = PROCESS_UPTIME.lock().unwrap().clone();
let start = *PROCESS_UPTIME.lock().unwrap();
let uptime = std::time::SystemTime::now().duration_since(start).unwrap();
let (days, hours, minutes, seconds) = (

View File

@@ -38,7 +38,7 @@ async fn main() {
tracing_subscriber::fmt::init();
dotenv::dotenv().expect("Failed to load .env file.");
let _ = PROCESS_UPTIME.lock().unwrap().clone();
let _ = *PROCESS_UPTIME.lock().unwrap();
let token =
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
@@ -81,7 +81,7 @@ async fn main() {
let options = poise::FrameworkOptions {
commands,
prefix_options: poise::PrefixFrameworkOptions {
prefix: Some(prefix.to_string().into()),
prefix: Some(prefix.to_string()),
edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan(
Duration::from_secs(3600),
))),