Adding ablity to delete user from points table
This commit is contained in:
parent
01e46f873f
commit
17a59ad516
@ -76,12 +76,6 @@ namespace ChaosBot.Database.Repository
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static int Add(string userId, int points, string guildId)
|
||||
{
|
||||
Dictionary<string, object> selectfilterDict = new Dictionary<string, object>();
|
||||
|
||||
@ -8,7 +8,8 @@ using Discord.Commands;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using ChaosBot.Database.Repository;
|
||||
|
||||
using ChaosBot.Database;
|
||||
using System.Data;
|
||||
|
||||
namespace ChaosBot.Discord.Modules
|
||||
{
|
||||
@ -35,7 +36,8 @@ namespace ChaosBot.Discord.Modules
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("Moderation commands:");
|
||||
sb.AppendLine($"{prefix}points add <discord mention> <amount>");
|
||||
sb.AppendLine($"{prefix}point remove");
|
||||
sb.AppendLine($"{prefix}point remove <discord mention> <amount>");
|
||||
sb.AppendLine($"{prefix}point delete <discord mention>");
|
||||
|
||||
/*
|
||||
* Add the string to the Embed
|
||||
@ -89,5 +91,29 @@ namespace ChaosBot.Discord.Modules
|
||||
else
|
||||
await ReplyAsync($"{Context.User.Mention} has tried to remove {amount} points from <@{userId}> they only had {cur} points. None were taken...", false);
|
||||
}
|
||||
|
||||
[Command("points delete")]
|
||||
[RequireUserPermission(ChannelPermission.ManageMessages)]
|
||||
public async Task DeletePoints(string userMention)
|
||||
{
|
||||
ulong userId = Convert.ToUInt64(userMention.Substring(3, userMention.Length - 4));
|
||||
Dictionary<string, object> filterColumns = new Dictionary<string, object>
|
||||
{
|
||||
{ "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(*)"];
|
||||
if (matches > 0)
|
||||
{
|
||||
Controller.DeleteQuery("PointsTable", filterColumns);
|
||||
await ReplyAsync($"{Context.User.Mention} has removed <@{userId}> from the database.", false);
|
||||
}
|
||||
else
|
||||
await ReplyAsync($"{Context.User.Mention} has failed to remove <@{userId}> from the database, <@{userId}> does not exist. ", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user