Rework DeletePoints method to use Count Repository method
This commit is contained in:
parent
343e0e7626
commit
9871d402de
@ -102,18 +102,22 @@ namespace ChaosBot.Discord.Modules
|
||||
{ "userId", userId },
|
||||
{ "guildId", Context.Guild.Id }
|
||||
};
|
||||
Dictionary<string, object> selectfilterDict = new Dictionary<string, object>();
|
||||
selectfilterDict.Add("userId", userId);
|
||||
selectfilterDict.Add("guildId", Context.Guild.Id);
|
||||
DataTable dt = Controller.SelectQuery(Table, "COUNT(*)", selectfilterDict);
|
||||
int matches = dt.Rows[0]["COUNT(*)"];
|
||||
|
||||
int matches = PointsRepository.Count(userId.ToString(), Context.Guild.Id.ToString());
|
||||
if (matches > 0)
|
||||
{
|
||||
Controller.DeleteQuery("PointsTable", filterColumns);
|
||||
await ReplyAsync($"{Context.User.Mention} has removed <@{userId}> from the database.", false);
|
||||
}
|
||||
{
|
||||
Controller.DeleteQuery("PointsTable", filterColumns);
|
||||
|
||||
string message = $"{Context.User.Mention} has removed <@{userId}> from the database.";
|
||||
await ReplyAsync(message, false);
|
||||
_logger.Info($"PointsCommands.DeletePoints: {message}");
|
||||
}
|
||||
else
|
||||
await ReplyAsync($"{Context.User.Mention} has failed to remove <@{userId}> from the database, <@{userId}> does not exist. ", false);
|
||||
{
|
||||
string message = $"{Context.User.Mention} has failed to remove <@{userId}> from the database, <@{userId}> does not exist.";
|
||||
await ReplyAsync(message, false);
|
||||
_logger.Warn($"PointsCommands.DeletePoints: {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user