Make errorhandler and languagehandler async, await all database actions
This commit is contained in:
parent
926a632641
commit
95618b1f8b
46 changed files with 181 additions and 137 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.Net;
|
||||
using Geekbot.net.Lib.Localization;
|
||||
|
@ -34,11 +35,11 @@ namespace Geekbot.net.Lib.ErrorHandling
|
|||
}
|
||||
}
|
||||
|
||||
public void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def")
|
||||
public async Task HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def")
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorString = errorMessage == "def" ? _translation.GetString(context.Guild.Id, "errorHandler", "SomethingWentWrong") : errorMessage;
|
||||
var errorString = errorMessage == "def" ? await _translation.GetString(context.Guild.Id, "errorHandler", "SomethingWentWrong") : errorMessage;
|
||||
var errorObj = SimpleConextConverter.ConvertContext(context);
|
||||
if (e.Message.Contains("50007")) return;
|
||||
if (e.Message.Contains("50013")) return;
|
||||
|
@ -86,9 +87,9 @@ namespace Geekbot.net.Lib.ErrorHandling
|
|||
}
|
||||
}
|
||||
|
||||
public async void HandleHttpException(HttpException e, ICommandContext context)
|
||||
public async Task HandleHttpException(HttpException e, ICommandContext context)
|
||||
{
|
||||
var errorStrings = _translation.GetDict(context, "httpErrors");
|
||||
var errorStrings = await _translation.GetDict(context, "httpErrors");
|
||||
switch(e.HttpCode)
|
||||
{
|
||||
case HttpStatusCode.Forbidden:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.Net;
|
||||
|
||||
|
@ -6,7 +7,7 @@ namespace Geekbot.net.Lib.ErrorHandling
|
|||
{
|
||||
public interface IErrorHandler
|
||||
{
|
||||
void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def");
|
||||
void HandleHttpException(HttpException e, ICommandContext context);
|
||||
Task HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def");
|
||||
Task HandleHttpException(HttpException e, ICommandContext context);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue