Skip to content

Commit

Permalink
Fixing invalid requests for invalid usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAunvik committed Jun 1, 2020
1 parent 3806c35 commit 9d6b059
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion AnimeListBot/Handler/Database/Objects/DiscordUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Net;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
Expand Down Expand Up @@ -493,7 +494,12 @@ public async Task<bool> UpdateMALInfo(string username)
return malProfile != null;
}catch(JikanRequestException e)
{
if (e.ResponseCode == System.Net.HttpStatusCode.NotFound) return false;
switch (e.ResponseCode)
{
case HttpStatusCode.NotFound:
case HttpStatusCode.BadRequest:
return false;
}
throw new Exception("MyAnimeList is having troubles, try again later. Join support server for status updates: https://discord.gg/Q9cf46R \nError ResponseCode: " + e.ResponseCode + "");
}
}
Expand Down
4 changes: 2 additions & 2 deletions AnimeListBot/Modules/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task SetupMalProfile(EmbedHandler embed, DiscordUser user, string u
{
if (!await user.UpdateMALInfo(username))
{
embed.Title = "Invalid Username.";
embed.Title = "Invalid Username/URL.";
user.MalUsername = string.Empty;
await embed.UpdateEmbed();
return;
Expand All @@ -130,7 +130,7 @@ public async Task SetupAnilistProfile(EmbedHandler embed, DiscordUser user, stri
{
if (!await user.UpdateAnilistInfo(username))
{
embed.Title = "Invalid Username.";
embed.Title = "Invalid Username/URL.";
user.AnilistUsername = string.Empty;
await embed.UpdateEmbed();
return;
Expand Down

0 comments on commit 9d6b059

Please sign in to comment.