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
|
@ -45,7 +45,7 @@ namespace Geekbot.net.Commands.Randomness.Cat
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Geekbot.net.Commands.Randomness
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Geekbot.net.Commands.Randomness.Chuck
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Geekbot.net.Commands.Randomness.Dad
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Geekbot.net.Commands.Randomness.Dog
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Geekbot.net.Commands.Randomness
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Geekbot.net.Commands.Randomness
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Geekbot.net.Commands.Randomness
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
await _errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ namespace Geekbot.net.Commands.Randomness
|
|||
|
||||
await ReplyAsync($"{Context.User.Username} slapped {user.Username} with a {things[new Random().Next(things.Count - 1)]}");
|
||||
|
||||
UpdateRecieved(user.Id);
|
||||
UpdateGiven(Context.User.Id);
|
||||
await UpdateRecieved(user.Id);
|
||||
await UpdateGiven(Context.User.Id);
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -91,21 +91,21 @@ namespace Geekbot.net.Commands.Randomness
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateGiven(ulong userId)
|
||||
private async Task UpdateGiven(ulong userId)
|
||||
{
|
||||
var user = GetUser(userId);
|
||||
var user = await GetUser(userId);
|
||||
user.Given++;
|
||||
_database.Slaps.Update(user);
|
||||
}
|
||||
|
||||
private void UpdateRecieved(ulong userId)
|
||||
private async Task UpdateRecieved(ulong userId)
|
||||
{
|
||||
var user = GetUser(userId);
|
||||
var user = await GetUser(userId);
|
||||
user.Recieved++;
|
||||
_database.Slaps.Update(user);
|
||||
}
|
||||
|
||||
private SlapsModel GetUser(ulong userId)
|
||||
private async Task<SlapsModel> GetUser(ulong userId)
|
||||
{
|
||||
var user = _database.Slaps.FirstOrDefault(e =>
|
||||
e.GuildId.Equals(Context.Guild.Id.AsLong()) &&
|
||||
|
@ -121,7 +121,7 @@ namespace Geekbot.net.Commands.Randomness
|
|||
Recieved = 0,
|
||||
Given = 0
|
||||
});
|
||||
_database.SaveChanges();
|
||||
await _database.SaveChangesAsync();
|
||||
return _database.Slaps.FirstOrDefault(e =>
|
||||
e.GuildId.Equals(Context.Guild.Id.AsLong()) &&
|
||||
e.UserId.Equals(userId.AsLong()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue