public async Task BanUserAsync(ulong userId) { using (DatabaseAction action = this.DatabaseActionFactory.Create()) { await action.AddCommandBannedUser(userId); } Logger.Information($"User {this.Context.User.Id} banned user {userId} from using commands"); await this.Context.Channel.SendMessageAsync($"Banned user with ID {userId} from running commands."); }
public async Task UnbanUser() { const ulong bannedUser = 123; this.CreateHandler(out BotOwnerCommandHandler handler, out MessageStore messageStore); using (BotConfigurationContext context = this.botConfigurationfactory.Create()) using (DatabaseAction action = new DatabaseAction(context)) { await action.AddCommandBannedUser(bannedUser); } await handler.UnbanUserAsync(bannedUser); using (BotConfigurationContext context = this.botConfigurationfactory.Create()) using (DatabaseAction action = new DatabaseAction(context)) { bool banned = await action.GetCommandBannedAsync(bannedUser); Assert.IsFalse(banned, "User should be unbanned"); } }