Made token revocation errors more obvious

main
DaXcess 2022-11-25 15:50:27 +01:00
parent 784c2514ac
commit 3aa708a070
No known key found for this signature in database
GPG Key ID: CF78CC72F0FD5EAD
3 changed files with 29 additions and 0 deletions

View File

@ -242,6 +242,18 @@ pub fn run(ctx: Context, command: ApplicationCommandInteraction) -> CommandOutpu
) )
.await; .await;
return;
} else if let SessionCreateError::NoLongerSpotifyError = why {
update_message(
&ctx,
&command,
EmbedBuilder::new()
.title("Cannot join voice channel")
.description("Spoticord no longer has access to your Spotify account. Use </link:1036714850367320136> or go to [the accounts website](https://account.spoticord.com/) to relink your Spotify account.")
.status(Status::Error)
.build(),
).await;
return; return;
} }
@ -284,6 +296,18 @@ pub fn run(ctx: Context, command: ApplicationCommandInteraction) -> CommandOutpu
) )
.await; .await;
return;
} else if let SessionCreateError::NoLongerSpotifyError = why {
update_message(
&ctx,
&command,
EmbedBuilder::new()
.title("Cannot join voice channel")
.description("Spoticord no longer has access to your Spotify account. Use </link:1036714850367320136> or go to [the accounts website](https://account.spoticord.com/) to relink your Spotify account.")
.status(Status::Error)
.build(),
).await;
return; return;
} }

View File

@ -16,6 +16,9 @@ pub enum SessionCreateError {
#[error("The user has not linked their Spotify account")] #[error("The user has not linked their Spotify account")]
NoSpotifyError, NoSpotifyError,
#[error("The application no longer has access to the user's Spotify account")]
NoLongerSpotifyError,
#[error("An error has occured while communicating with the database")] #[error("An error has occured while communicating with the database")]
DatabaseError, DatabaseError,

View File

@ -153,6 +153,8 @@ impl SpoticordSession {
if let DatabaseError::InvalidStatusCode(code) = why { if let DatabaseError::InvalidStatusCode(code) = why {
if code == 404 { if code == 404 {
return Err(SessionCreateError::NoSpotifyError); return Err(SessionCreateError::NoSpotifyError);
} else if code == 400 {
return Err(SessionCreateError::NoLongerSpotifyError);
} }
} }