4 Commits

22 changed files with 60 additions and 2301 deletions

9
.gitmodules vendored
View File

@@ -1,3 +1,12 @@
[submodule "libs/songbird"] [submodule "libs/songbird"]
path = libs/songbird path = libs/songbird
url = git@github.com:eRgo35/songbird.git 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
[submodule "libs/spotify-parser"]
path = libs/spotify-parser
url = git@github.com:eRgo35/spotify-parser.git

7
Cargo.lock generated
View File

@@ -1349,7 +1349,7 @@ dependencies = [
[[package]] [[package]]
name = "lyra" name = "lyra"
version = "0.9.0" version = "0.9.1"
dependencies = [ dependencies = [
"dotenv", "dotenv",
"fancy-regex", "fancy-regex",
@@ -2720,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",
@@ -2829,6 +2828,8 @@ dependencies = [
[[package]] [[package]]
name = "songbird" name = "songbird"
version = "0.4.3" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "338dd182f9f084f583c4c0db38588e28a34778ecec288208cf0b61c378ac90d1"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"audiopus", "audiopus",

View File

@@ -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."
@@ -11,22 +11,22 @@ 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"
songbird = { path = "./libs/songbird", version = "0.4", default-features = true, features = [ songbird = { version = "0.4.3", default-features = true, features = [
"builtin-queue", "builtin-queue",
] } ] }
serenity = { features = [ serenity = { default-features = true, features = [
"cache", "cache",
"framework", "framework",
"standard_framework", "standard_framework",
@@ -49,3 +49,7 @@ 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" 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

1
libs/serenity Submodule

Submodule libs/serenity added at 658b6a7261

1
libs/spotify-parser Submodule

Submodule libs/spotify-parser added at 4398512b5c

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
[package]
name = "lib-spotify-parser"
version = "1.0.0"
edition = "2021"
[dependencies]
regex = "1.10.6"
reqwest = { version = "0.12.5", features = ["blocking", "rustls-tls"] }
scraper = "0.19.1"
serde = "1.0.204"
serde_json = "1.0.122"
tokio = { version = "1.39.2", features = ["macros"] }

View File

@@ -1,14 +0,0 @@
use std::fmt;
#[derive(Debug)]
pub enum ParseError {
InvalidUrl,
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Invalid URL")
}
}
impl std::error::Error for ParseError {}

View File

@@ -1,154 +0,0 @@
mod error;
mod parser;
mod retriever;
use error::ParseError;
use parser::{parse_list, parse_single, USER_AGENT};
use regex::Regex;
use reqwest;
use retriever::{retrieve_async_track, retrieve_async_tracks, retrieve_track, retrieve_tracks};
pub fn retrieve_url(url: &str) -> Result<Vec<String>, ParseError> {
let spotify_regex: Regex = Regex::new(r"https?:\/\/(?:embed\.|open\.)spotify\.com\/(track|album|playlist)\/([a-zA-Z0-9]+)(?:\?si=[\w-]+)?").unwrap();
if let Some(captures) = spotify_regex.captures(url) {
let category = captures.get(1).unwrap().as_str();
let id = captures.get(2).unwrap().as_str();
match category {
"track" => {
let track = retrieve_track(category, id).unwrap();
Ok(vec![track])
}
"playlist" | "album" => {
let tracks = retrieve_tracks(category, id).unwrap();
Ok(tracks)
}
_ => Err(ParseError::InvalidUrl),
}
} else {
Err(ParseError::InvalidUrl)
}
}
pub async fn retrieve_async_url(url: &str) -> Result<Vec<String>, ParseError> {
let spotify_regex: Regex = Regex::new(r"https?:\/\/(?:embed\.|open\.)spotify\.com\/(track|album|playlist)\/([a-zA-Z0-9]+)(?:\?si=[\w-]+)?").unwrap();
if let Some(captures) = spotify_regex.captures(url) {
let category = captures.get(1).unwrap().as_str();
let id = captures.get(2).unwrap().as_str();
match category {
"track" => {
let track = retrieve_async_track(category, id).await.unwrap();
Ok(vec![track])
}
"playlist" | "album" => {
let tracks = retrieve_async_tracks(category, id).await.unwrap();
Ok(tracks)
}
_ => Err(ParseError::InvalidUrl),
}
} else {
Err(ParseError::InvalidUrl)
}
}
#[cfg(test)]
mod tests {
use super::*;
const TRACK: &str = "https://open.spotify.com/track/4PTG3Z6ehGkBFwjybzWkR8?si=e0a8c8ada8284e43";
const MULTIPLE_ARTISTS_TRACK: &str =
"https://open.spotify.com/track/1O0SdrryPeGp6eSSUibdgo?si=4ae58febe9e74eae";
const PLAYLIST: &str =
"https://open.spotify.com/playlist/37i9dQZF1DZ06evO05tE88?si=e0c6f44d176f44e6";
const ALBUM: &str =
"https://open.spotify.com/album/6eUW0wxWtzkFdaEFsTJto6?si=_grLtlNySNyfJTZr8tP44Q";
#[test]
fn check_track() {
let track: Vec<&str> = vec!["Rick Astley - Never Gonna Give You Up"];
assert_eq!(retrieve_url(TRACK).unwrap(), track);
}
#[test]
fn check_multiple_artists_track() {
let track: Vec<&str> = vec!["Will o' the wisp, Rick Astley - Blood on My Tie"];
assert_eq!(retrieve_url(MULTIPLE_ARTISTS_TRACK).unwrap(), track);
}
#[test]
fn check_playlist() {
let playlist: Vec<&str> = vec![
"Rick Astley - Never Gonna Give You Up",
"Rick Astley - Take Me to Your Heart (2023 Remaster)",
"Rick Astley - Cry for Help - Single Edit",
"Rick Astley - Never Gonna Stop",
"Rick Astley - Together Forever",
"Rick Astley - Hold Me in Your Arms (7\" Version)",
"Rick Astley - Angels on My Side",
"New Kids On The Block, Salt-N-Pepa, Rick Astley, En Vogue - Bring Back The Time",
"Rick Astley - Whenever You Need Somebody",
"Rick Astley - She Wants to Dance with Me (2023 Remaster)",
"Rick Astley - Dippin My Feet",
"Rick Astley - My Arms Keep Missing You",
"Rick Astley - Don't Say Goodbye",
"Rick Astley - Dance",
"Rick Astley - Giving Up On Love (7'' Pop Version)",
"Rick Astley - Never Gonna Give You Up (Cake Mix)",
"Rick Astley - It Would Take a Strong Strong Man",
"Rick Astley - Driving Me Crazy",
"Rick Astley - Beautiful Life",
"Rick Astley - I Don't Want to Lose Her",
"Rick Astley - Keep Singing",
"Rick Astley - Forever and More",
"Rick Astley - Hopelessly",
"Rick Astley - When I Fall in Love",
"Rick Astley - Every One of Us",
"Rick Astley - High Enough",
"Rick Astley - Ain't Too Proud to Beg (2023 Remaster)",
"Rick Astley - I'll Never Let You Down",
"Trevor Horn, Rick Astley - Owner Of A Lonely Heart",
"Rick Astley - Letting Go",
"Rick Astley - Never Knew Love",
"Rick Astley - Lights Out - Radio Edit",
"Rick Astley - Try",
"Rick Astley - Dial My Number (2023 Remaster)",
"Rick Astley - Wish Away",
"Rick Astley - Giant",
"Rick Astley - Move Right Out",
"Rick Astley - Till Then (Time Stands Still) (2023 Remaster)",
"Rick Astley - Pray with Me",
"Rick Astley - I Don't Want to Be Your Lover",
"Will o' the wisp, Rick Astley - Blood on My Tie",
"Rick Astley - Can't Help Falling in Love",
"Rick Astley - I Like the Sun",
"Rick Astley - She Makes Me",
"Rick Astley - Body and Soul",
"Rick Astley - (They Long to Be) Close to You",
"Rick Astley - Unwanted (Official Song from the Podcast)",
"Rick Astley - Last Night on Earth",
"Rick Astley - Everlong - Acoustic Version",
"Rick Astley - Superman",
];
assert_eq!(retrieve_url(PLAYLIST).unwrap(), playlist);
}
#[test]
fn check_album() {
let album: Vec<&str> = vec![
"Rick Astley - Never Gonna Give You Up",
"Rick Astley - Whenever You Need Somebody",
"Rick Astley - Together Forever",
"Rick Astley - It Would Take a Strong Strong Man",
"Rick Astley - The Love Has Gone",
"Rick Astley - Don't Say Goodbye",
"Rick Astley - Slipping Away",
"Rick Astley - No More Looking for Love",
"Rick Astley - You Move Me",
"Rick Astley - When I Fall in Love",
];
assert_eq!(retrieve_url(ALBUM).unwrap(), album);
}
}

View File

@@ -1,70 +0,0 @@
use scraper::{Html, Selector};
use serde_json::Value;
use std::error::Error;
#[derive(Debug, Clone)]
pub(crate) struct SpotifyTrack {
pub title: String,
pub artist: String,
}
pub(crate) const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
pub(crate) fn parse_single(content: String) -> Result<SpotifyTrack, Box<dyn Error>> {
let document = Html::parse_document(&content);
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
if let Some(script_element) = document.select(&selector).next() {
let json_str = script_element.inner_html();
let json_value: Value = serde_json::from_str(&json_str)?;
let metadata = &json_value["props"]["pageProps"]["state"]["data"]["entity"];
// println!("{metadata:?}");
let title = metadata["title"].as_str().unwrap().to_string();
let artists = metadata["artists"].as_array().unwrap();
let artists_list: Vec<String> = artists
.iter()
.map(|artist| artist["name"].as_str().unwrap().to_string())
.collect();
let artist: String = artists_list.join(", ").to_string();
let track = SpotifyTrack { title, artist };
Ok(track)
} else {
Err("Could not find element".into())
}
}
pub(crate) fn parse_list(content: String) -> Result<Vec<SpotifyTrack>, Box<dyn Error>> {
let document = Html::parse_document(&content);
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
if let Some(script_element) = document.select(&selector).next() {
let json_str = script_element.inner_html();
let json_value: Value = serde_json::from_str(&json_str)?;
let metadata = &json_value["props"]["pageProps"]["state"]["data"]["entity"]["trackList"]
.as_array()
.unwrap();
// println!("{metadata:?}");
let tracks: Vec<SpotifyTrack> = metadata
.iter()
.map(|track| {
let title = track["title"].as_str().unwrap().to_string();
let artist = track["subtitle"].as_str().unwrap().to_string();
SpotifyTrack { title, artist }
})
.collect();
// println!("{tracks:?}");
Ok(tracks)
} else {
Err("Could not find element".into())
}
}

View File

@@ -1,85 +0,0 @@
use crate::*;
pub fn retrieve_track(category: &str, id: &str) -> Result<String, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::blocking::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().unwrap();
let content = response.text().unwrap();
let parsed_content = parse_single(content).unwrap();
Ok(format!(
"{} - {}",
parsed_content.artist, parsed_content.title
))
}
pub fn retrieve_tracks(category: &str, id: &str) -> Result<Vec<String>, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::blocking::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().unwrap();
let content = response.text().unwrap();
let parsed_content = parse_list(content).unwrap();
let tracks: Vec<String> = parsed_content
.iter()
.map(|track| format!("{} - {}", track.artist, track.title))
.collect();
Ok(tracks)
}
pub async fn retrieve_async_track(category: &str, id: &str) -> Result<String, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().await.unwrap();
let content = response.text().await.unwrap();
let parsed_content = parse_single(content).unwrap();
Ok(format!(
"{} - {}",
parsed_content.artist, parsed_content.title
))
}
pub async fn retrieve_async_tracks(category: &str, id: &str) -> Result<Vec<String>, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().await.unwrap();
let content = response.text().await.unwrap();
let parsed_content = parse_list(content).unwrap();
let tracks: Vec<String> = parsed_content
.iter()
.map(|track| format!("{} - {}", track.artist, track.title))
.collect();
Ok(tracks)
}

View File

@@ -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())

View File

@@ -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(

View File

@@ -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)

View File

@@ -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(

View File

@@ -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()))

View File

@@ -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()))

View File

@@ -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)

View File

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

View File

@@ -38,7 +38,7 @@ 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().clone(); 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!");
@@ -81,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),
))), ))),