public async Task <Result <FeedbackMessage> > ViewRoleplayAsync ( [AutocompleteProvider("roleplay::any")] Roleplay roleplay ) { var getDedicatedChannelResult = DedicatedChannelService.GetDedicatedChannel(roleplay); if (!getDedicatedChannelResult.IsSuccess) { return(new UserError ( "The given roleplay doesn't have a dedicated channel. Try using \"!rp export\" instead." )); } if (!roleplay.IsPublic && roleplay.ParticipatingUsers.All(p => p.User.DiscordID != _context.User.ID)) { return(new UserError ( "You don't have permission to view that roleplay." )); } var dedicatedChannel = getDedicatedChannelResult.Entity; var setVisibility = await _dedicatedChannels.SetChannelVisibilityForUserAsync ( dedicatedChannel, _context.User.ID, true ); if (!setVisibility.IsSuccess) { return(Result <FeedbackMessage> .FromError(setVisibility)); } return(new FeedbackMessage ( $"The roleplay \"{roleplay.Name}\" is now visible in <#{dedicatedChannel}>.", _feedback.Theme.Secondary )); }
public async Task ViewRoleplayAsync(Roleplay roleplay) { var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!getDedicatedChannelResult.IsSuccess) { await _feedback.SendErrorAsync ( this.Context, "The given roleplay doesn't have a dedicated channel. Try using \"!rp export\" instead." ); return; } var user = this.Context.User; if (!roleplay.IsPublic && roleplay.ParticipatingUsers.All(p => p.User.DiscordID != (long)user.Id)) { await _feedback.SendErrorAsync ( this.Context, "You don't have permission to view that roleplay." ); return; } var dedicatedChannel = getDedicatedChannelResult.Entity; await _dedicatedChannels.SetChannelVisibilityForUserAsync(dedicatedChannel, user, true); var channelMention = MentionUtils.MentionChannel(dedicatedChannel.Id); await _feedback.SendConfirmationAsync ( this.Context, $"The roleplay \"{roleplay.Name}\" is now visible in {channelMention}." ); }