/// <summary> /// Checks a user's warn status /// </summary> /// <param name="user"></param> public static void CheckUserWarnStatus(SocketGuildUser user) { if (user.IsBot) { return; } if (user.GuildPermissions.Administrator) { return; } UserAccountServerData userAccount = GetAccount(user).GetOrCreateServer(user.Guild.Id); ServerList server = ServerListsManager.GetServer(user.Guild); //Warnings needed for kick and ban are set to the same amount, and the user has enough warnings so just straight ban if (server.WarningsKickAmount == server.WarningsBanAmount && userAccount.Warnings >= server.WarningsKickAmount) { user.BanUser((SocketUser)Global.BotUser, $"Banned for having {server.WarningsKickAmount} warnings."); } //Enough warnings for a kick else if (userAccount.Warnings == server.WarningsKickAmount) { user.KickUser((SocketUser)Global.BotUser, $"Kicked for having {server.WarningsKickAmount} warnings."); } //Enough warnings for a ban else if (userAccount.Warnings >= server.WarningsBanAmount) { user.BanUser((SocketUser)Global.BotUser, $"Banned for having {server.WarningsBanAmount} warnings."); } }
public async Task BanUser(SocketGuildUser user, [Remainder] string reason = "") { if (user.GuildPermissions.Administrator) { await Context.Channel.SendMessageAsync( "Cannot ban this user due to them having Administrator rights!"); return; } user.BanUser((SocketGuildUser)Context.User, reason); await Context.Channel.SendMessageAsync($"The user {user.Username} was banned."); }