Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Updated reason inserting for Kick and added reason for ban
Browse files Browse the repository at this point in the history
  • Loading branch information
fajnyCreeper committed Oct 17, 2017
1 parent e0a4260 commit 1fb6432
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
18 changes: 17 additions & 1 deletion source/WarnBot/DBConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,23 @@ public static void Kick(string user, UInt64 guild, string reason)
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "UPDATE warnings SET kicks=kicks+1, reason=\"" + reason + "\" WHERE guild=" + guild + " AND user=@User";
cmd.CommandText = "UPDATE warnings SET kicks=kicks+1, kickReason=\"" + reason + "\" WHERE guild=" + guild + " AND user=@User";
cmd.Prepare();
cmd.Parameters.AddWithValue("@User", user);
cmd.ExecuteNonQuery();
if (conn != null)
{
conn.Close();
}
}
public static void Ban(string user, UInt64 guild, string reason)
{
MySqlConnection conn = null;
conn = new MySqlConnection(cs);
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "UPDATE warnings SET banReason=\"" + reason + "\" WHERE guild=" + guild + " AND user=@User";
cmd.Prepare();
cmd.Parameters.AddWithValue("@User", user);
cmd.ExecuteNonQuery();
Expand Down
26 changes: 17 additions & 9 deletions source/WarnBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,24 @@ private async Task MessageReceived(SocketMessage msg)
{
if ((DBConnector.PermCheck(msg.Author.Id, chnl.Guild.Id)[0] >= 1 || msg.Author.Id == chnl.Guild.Owner.Id) && ulong.Parse(usr2ulong) != msg.Author.Id)
{
DBConnector.Prepare(user, chnl.Guild.Id);
int count = DBConnector.WarnCount(user, chnl.Guild.Id) + 1;
if (count > 3)
if (context != "")
{
count = 1;
DBConnector.Prepare(user, chnl.Guild.Id);
int count = DBConnector.WarnCount(user, chnl.Guild.Id) + 1;
if (count > 3)
{
count = 1;
}
DBConnector.Warn(user, chnl.Guild.Id, count);
await msg.Channel.SendMessageAsync("Warned: " + user + "\nReason: " + context + "\nWarning " + count + "/3");
if (count == 3)
{
await msg.Channel.SendMessageAsync("User now can be kicked!");
}
}
DBConnector.Warn(user, chnl.Guild.Id, count);
await msg.Channel.SendMessageAsync("Warned: " + user + "\nReason: " + context + "\nWarning " + count + "/3");
if (count == 3)
else
{
await msg.Channel.SendMessageAsync("User now can be kicked!");
await msg.Channel.SendMessageAsync("You can't ban without a reason!");
}
}
else
Expand Down Expand Up @@ -147,6 +154,7 @@ private async Task MessageReceived(SocketMessage msg)
int kick = DBConnector.Info(user, chnl.Guild.Id)[1];
if (kick != 0 && (kick % 5) == 0)
{
DBConnector.Ban(user, chnl.Guild.Id, context);
await chnl.Guild.AddBanAsync(Convert.ToUInt64(usr2ulong), 0, context);
await msg.Channel.SendMessageAsync("Banned " + user + " for \"" + context + "\"");
}
Expand Down Expand Up @@ -223,7 +231,7 @@ private async Task MessageReceived(SocketMessage msg)
}
break;
case "/help":
await msg.Channel.SendMessageAsync("```Everyone:\n/about............................About this bot\n/example </command>...............Shows example of specified command\n/info <user>......................Shows warnings and kicks\n\nAdmins:\n/ban <user> <reason>..............Bans person\n/clear <user>.....................Clears warning count\n/kick <user> <reason>.............Kicks person\n/warn <user> <reason[optional]>...Give person warning\n\nOwner:\n/addusr <user> <K|KB>.............Adds user to Admins\n/rmusr <user> <K|KB>..............Remove user from Admins\n/updateusr <user> <K|KB> .........Updates permissions for user\n..................................K=Kick, KB=Kick and Ban```");
await msg.Channel.SendMessageAsync("```Everyone:\n/about............................About this bot\n/example </command>...............Shows example of specified command\n/info <user>......................Shows warnings and kicks\n\nAdmins:\n/ban <user> <reason>..............Bans person\n/clear <user>.....................Clears warning count\n/kick <user> <reason>.............Kicks person\n/warn <user> <reason>...Give person warning\n\nOwner:\n/addusr <user> <K|KB>.............Adds user to Admins\n/rmusr <user> <K|KB>..............Remove user from Admins\n/updateusr <user> <K|KB> .........Updates permissions for user\n..................................K=Kick, KB=Kick and Ban```");
break;
case "/addusr":
try
Expand Down

0 comments on commit 1fb6432

Please sign in to comment.