private async Task OnUserUnbanned(SocketUser user, SocketGuild server) { var banData = _banningService.GetBans(user.Id.ToString()); if (banData.Count > 0) { Logger.Write($"[OnUserUnbanned] {banData[0].Name} banned by {banData[0].ByName} for {banData[0].Reason}. Lifting..."); _banningService.RemoveBan(user.Id); } Logger.Write($"[OnUserUnbanned] {user.Username}"); }
public async Task Unban(string user = "") { if (Context.Channel.Id != _adminChannelId) { return; } if (user == null) { ReplyAsync("`/unban <userid, username>` - Removes a discord ban" + "\n" + "Search by a ID (*Open the ban list, Right click, Copy ID*)" + "\n" + "**TIP** Alternative to using this command is lifting the ban via discord UI"); return; } var bans = _banningService.GetBans(user); if (bans.Count == 0) { ReplyAsync("No bans found to lift."); return; } foreach (var ban in bans.Where(b => b.Lifted == 0)) { if (ban.ExpiresOn != null) { ReplyAsync($"<@{ban.Userid}> ({ban.Name}) by <@{ban.ByUserid}> ({ban.ByName}) on **{ban.BannedOn.DateTime.ToHumanReadableString()}** for **{ban.Reason}**. Ban expires on **{ban.ExpiresOn?.ToHumanReadableString()}**. Lifted."); } else { ReplyAsync($"<@{ban.Userid}> ({ban.Name}) by <@{ban.ByUserid}> ({ban.ByName}) on **{ban.BannedOn.DateTime.ToHumanReadableString()}** for **{ban.Reason}**. Ban is permanent. Lifted."); } _banningService.RemoveBan(ban.Userid); Context.Guild.RemoveBanAsync(ban.Userid); } }