Fixed spotify more

This commit is contained in:
2025-07-31 00:44:48 -05:00
parent 158633d077
commit d6ea8977a6
2 changed files with 7 additions and 13 deletions

2
Cargo.lock generated
View File

@ -4270,7 +4270,7 @@ dependencies = [
[[package]] [[package]]
name = "watcat" name = "watcat"
version = "0.3.0" version = "0.4.0"
dependencies = [ dependencies = [
"arabic_reshaper", "arabic_reshaper",
"dotenvy", "dotenvy",

View File

@ -2,7 +2,7 @@ extern crate dotenvy;
extern crate lastfm; extern crate lastfm;
extern crate reqwest; extern crate reqwest;
extern crate reqwest_middleware; extern crate reqwest_middleware;
use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache, HttpCacheOptions}; use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache, HttpCacheOptions,};
use serenity::async_trait; use serenity::async_trait;
use serenity::builder::{CreateAttachment, CreateMessage}; use serenity::builder::{CreateAttachment, CreateMessage};
@ -11,7 +11,7 @@ use serenity::model::id::UserId;
use serenity::prelude::*; use serenity::prelude::*;
extern crate magick_rust; extern crate magick_rust;
use magick_rust::{ColorspaceType, CompositeOperator, MagickWand, PixelWand, magick_wand_genesis, FilterType}; use magick_rust::{ColorspaceType, CompositeOperator, MagickWand, PixelWand, magick_wand_genesis, FilterType,};
use std::env; use std::env;
use std::sync::{Once, Arc}; use std::sync::{Once, Arc};
@ -25,7 +25,7 @@ extern crate sqlx;
use sqlx::sqlite::SqlitePool; use sqlx::sqlite::SqlitePool;
use rspotify::{ClientCredsSpotify, Credentials, clients::BaseClient,}; use rspotify::{ClientCredsSpotify, Credentials, clients::BaseClient,};
use rspotify::model::{enums::types::SearchType, search::SearchResult}; use rspotify::model::{enums::types::SearchType, search::SearchResult,};
use imagetext::fontdb::FontDB; use imagetext::fontdb::FontDB;
use imagetext::superfont::SuperFont; use imagetext::superfont::SuperFont;
@ -178,9 +178,9 @@ async fn spot(ctx: &Context, arg: &str, id: UserId) -> Reply {
Err(e) => return Reply::Text(format!("Failed to get track {e}")), Err(e) => return Reply::Text(format!("Failed to get track {e}")),
_ => return Reply::Text("Spotify search failed".to_owned()), _ => return Reply::Text("Spotify search failed".to_owned()),
}; };
match &tracks.items[0].external_urls.get("spotify") { match &tracks.items.first().map(|x| x.external_urls.get("spotify")) {
Some(url) => Reply::Text(url.to_owned().to_owned()), Some(Some(url)) => Reply::Text(url.to_owned().to_owned()),
None => Reply::Text("Unable to get spotify url".to_owned()), _ => Reply::Text("Unable to get spotify url".to_owned()),
} }
} }
@ -395,12 +395,6 @@ async fn set(ctx: &Context, arg: &str, id: UserId) -> Reply {
Reply::Text(format!("set user {arg}")) Reply::Text(format!("set user {arg}"))
} }
//macro_rules! cmd {
// (c:lit, abbr:lit, a:ident) => {
// (".k", $c, $a) | (".k", $a, $c) | (concat!(".k", $abbr), $ident, "")
// }
//}
#[async_trait] #[async_trait]
impl EventHandler for Handler { impl EventHandler for Handler {
async fn message(&self, ctx: Context, msg: Message) { async fn message(&self, ctx: Context, msg: Message) {