public async Task RemoveTournamentDirectorAsync(IGuildUser oldDirector, string tournamentName) { Verify.IsNotNull(oldDirector, nameof(oldDirector)); if (string.IsNullOrWhiteSpace(tournamentName)) { this.Logger.Debug("Couldn't remove director {id} for tournament with blank name", oldDirector.Id); return; } tournamentName = tournamentName.Trim(); TournamentsManager manager = this.GlobalManager.GetOrAdd(this.Context.Guild.Id, CreateTournamentsManager); // TODO: Harden this. Since it's not guaranteed to be the current tournament, we can't use the helper // methods if (!manager.TryGetTournament(tournamentName, out ITournamentState state)) { this.Logger.Debug( "Couldn't remove director {id} for nonexistent tournament {tournamentName}", oldDirector.Id, tournamentName); await this.Context.Channel.SendMessageAsync( BotStrings.TournamentDoesNotExist(tournamentName, this.Context.Guild.Name), options : RequestOptionsSettings.Default); return; } if (state.TryRemoveDirector(oldDirector.Id)) { this.Logger.Debug( "Removed {id} as a tournament director for {tournamentName}", oldDirector.Id, tournamentName); await this.Context.Channel.SendMessageAsync( BotStrings.RemovedTournamentDirector(tournamentName, this.Context.Guild.Name), options : RequestOptionsSettings.Default); return; } this.Logger.Debug( "User {id} is not a director for {tournamentName}, so could not be removed", oldDirector.Id, tournamentName); await this.Context.Channel.SendMessageAsync( BotStrings.UserNotTournamentDirector(tournamentName, this.Context.Guild.Name), options : RequestOptionsSettings.Default); }