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 },
|
{ "userId", userId },
|
||||||
{ "guildId", Context.Guild.Id }
|
{ "guildId", Context.Guild.Id }
|
||||||
};
|
};
|
||||||
Dictionary<string, object> selectfilterDict = new Dictionary<string, object>();
|
|
||||||
selectfilterDict.Add("userId", userId);
|
int matches = PointsRepository.Count(userId.ToString(), Context.Guild.Id.ToString());
|
||||||
selectfilterDict.Add("guildId", Context.Guild.Id);
|
|
||||||
DataTable dt = Controller.SelectQuery(Table, "COUNT(*)", selectfilterDict);
|
|
||||||
int matches = dt.Rows[0]["COUNT(*)"];
|
|
||||||
if (matches > 0)
|
if (matches > 0)
|
||||||
{
|
{
|
||||||
Controller.DeleteQuery("PointsTable", filterColumns);
|
Controller.DeleteQuery("PointsTable", filterColumns);
|
||||||
await ReplyAsync($"{Context.User.Mention} has removed <@{userId}> from the database.", false);
|
|
||||||
}
|
string message = $"{Context.User.Mention} has removed <@{userId}> from the database.";
|
||||||
|
await ReplyAsync(message, false);
|
||||||
|
_logger.Info($"PointsCommands.DeletePoints: {message}");
|
||||||
|
}
|
||||||
else
|
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