Made token revocation errors more obvious
This commit is contained in:
		
							parent
							
								
									784c2514ac
								
							
						
					
					
						commit
						3aa708a070
					
				| @ -242,6 +242,18 @@ pub fn run(ctx: Context, command: ApplicationCommandInteraction) -> CommandOutpu | ||||
|           ) | ||||
|           .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; | ||||
|         } | ||||
| 
 | ||||
| @ -284,6 +296,18 @@ pub fn run(ctx: Context, command: ApplicationCommandInteraction) -> CommandOutpu | ||||
|           ) | ||||
|           .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; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -16,6 +16,9 @@ pub enum SessionCreateError { | ||||
|   #[error("The user has not linked their Spotify account")] | ||||
|   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")] | ||||
|   DatabaseError, | ||||
| 
 | ||||
|  | ||||
| @ -153,6 +153,8 @@ impl SpoticordSession { | ||||
|         if let DatabaseError::InvalidStatusCode(code) = why { | ||||
|           if code == 404 { | ||||
|             return Err(SessionCreateError::NoSpotifyError); | ||||
|           } else if code == 400 { | ||||
|             return Err(SessionCreateError::NoLongerSpotifyError); | ||||
|           } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 DaXcess
						DaXcess