所以我有一个正在为一个计算机科学项目开发的机器人,但我的 kick 命令不起作用。我试过注释掉更新 SQL 和 ReplyAsync 行,但它不会踢用户。我是否为用户使用了错误的数据类型?
public class Kick : ModuleBase<SocketCommandContext>
{
OleDbConnection con;
OleDbDataAdapter da;
[Command("kick")]
[RequireUserPermission(GuildPermission.KickMembers)]
[RequireBotPermission(GuildPermission.KickMembers)]
public async Task KickUser(IGuildUser user, string reason = "No reason provided")
{
con = new OleDbConnection();
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BotDB.accdb";
da = new OleDbDataAdapter();
con.Open();
da.InsertCommand = new OleDbCommand($"UPDATE UserData SET NumKick = NumKick + 1 WHERE UserID = '{Convert.ToString(user.Id)}'");
da.InsertCommand.ExecuteNonQuery();
con.Close();
await ReplyAsync($"{user.Nickname} was kicked from the server for '{reason}'");
await user.KickAsync(reason);
}
}
POPMUISE
相关分类