public Task AddTournamentDirectorAsync(IGuildUser newDirector, string tournamentName) { Verify.IsNotNull(newDirector, nameof(newDirector)); if (string.IsNullOrWhiteSpace(tournamentName)) { this.Logger.Debug("Did not add {id} to tournament with blank name", newDirector.Id); return(Task.CompletedTask); } TournamentsManager manager = this.GlobalManager.GetOrAdd(this.Context.Guild.Id, CreateTournamentsManager); ITournamentState state = new TournamentState(this.Context.Guild.Id, tournamentName.Trim()); bool updateSuccessful = state.TryAddDirector(newDirector.Id); manager.AddOrUpdateTournament( tournamentName, state, (name, tournamentState) => { updateSuccessful = tournamentState.TryAddDirector(newDirector.Id); return(tournamentState); }); // TODO: Need to handle this differently depending on the stage. Completed shouldn't do anything, and // after RoleSetup we should give them the TD role. if (updateSuccessful) { this.Logger.Debug( "Added {id} as a tournament director for {tournamentName}", newDirector.Id, tournamentName); return(this.SendChannelMessage( BotStrings.AddTournamentDirectorSuccessful(tournamentName, this.Context.Guild.Name))); } this.Logger.Debug( "{id} already a tournament director for {tournamentName}", newDirector.Id, tournamentName); return(this.SendChannelMessage( BotStrings.UserAlreadyTournamentDirector(tournamentName, this.Context.Guild.Name))); }