Skip to content

Commit

Permalink
Able to add a different jikan rest site
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAunvik committed Jun 7, 2020
1 parent 9d6b059 commit cd85245
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion AnimeListBot/Handler/Database/DatabaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task<DiscordUser> GetUserById(ulong id, bool forceUpdate = false)

public bool DoesUserIdExist(ulong id)
{
return dbConn.DiscordUser.Find(id) != null;
return dbConn.DiscordUser.ToList().Find(x => x.UserId == id) != null;
}

public async Task<bool> CreateUser(DiscordUser user)
Expand Down
3 changes: 3 additions & 0 deletions AnimeListBot/Handler/Utils/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class Config
public ulong test_error_channel;
public ulong test_channel;

// Jikan
public string jikan_api;

// Database
public string ip;
public int port;
Expand Down
3 changes: 2 additions & 1 deletion AnimeListBot/Modules/AutoAdder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ await dmChannel.SendMessageAsync(returnMessage +
"\nPlease use the following link formats:\n" +
"MAL: `https://myanimelist.net/profile/[username]` \n" +
"Anilist: `https://anilist.co/user/[username]`");
await message.DeleteAsync();

await PermissionWrapper.DeleteMessage((IUserMessage)message);
return;
}

Expand Down
7 changes: 6 additions & 1 deletion AnimeListBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public async Task RunBotAsync(string[] args)
gitStatus = File.ReadAllText("git_status.txt");
}

_jikan = new Jikan(true, surpressException: false);
if (!string.IsNullOrEmpty(bot_config.jikan_api)) {
_jikan = new Jikan(bot_config.jikan_api, surpressException: false);
}else
{
_jikan = new Jikan(true, surpressException: false);
}
_sauceNao = new SauceNao(bot_config.saucenao_token);
_dbl = new AuthDiscordBotListApi(botID, bot_config.dbl_token);

Expand Down
8 changes: 5 additions & 3 deletions AnimeListBot/config_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

"cluster_id": 0,
"override_shard_amount": 0,
"ignoredExceptionMessages": ["Server requested a reconnect", "WebSocket connection was closed"],

"ignoredExceptionMessages": [ "Server requested a reconnect", "WebSocket connection was closed" ],

"dbl_token": "Discord Bot List Token",

"jikan_api": "http://localhost:8000/v3/",

"ip": "localhost",
"port": 5432,
"catalog": "animelistbot",
Expand Down

0 comments on commit cd85245

Please sign in to comment.