public async Task SetRoleplayNameAsync ( [NotNull] string newRoleplayName, [NotNull] [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var result = await _roleplays.SetRoleplayNameAsync(this.Context, roleplay, newRoleplayName); if (!result.IsSuccess) { await _feedback.SendErrorAsync(this.Context, result.ErrorReason); return; } var getDedicatedChannelResult = await _roleplays.GetDedicatedRoleplayChannelAsync ( this.Context.Guild, roleplay ); if (getDedicatedChannelResult.IsSuccess) { var dedicatedChannel = getDedicatedChannelResult.Entity; await dedicatedChannel.ModifyAsync(p => p.Name = $"{roleplay.Name}-rp"); } await _feedback.SendConfirmationAsync(this.Context, "Roleplay name set."); }
public async Task JoinRoleplayAsync([NotNull] Roleplay roleplay) { var addUserResult = await _roleplays.AddUserToRoleplayAsync(this.Context, roleplay, this.Context.Message.Author); if (!addUserResult.IsSuccess) { await _feedback.SendErrorAsync(this.Context, addUserResult.ErrorReason); return; } // Ensure the user has the correct permissions for the dedicated channel var getDedicatedChannelResult = await _roleplays.GetDedicatedRoleplayChannelAsync(this.Context.Guild, roleplay); if (getDedicatedChannelResult.IsSuccess) { var dedicatedChannel = getDedicatedChannelResult.Entity; if (roleplay.IsActive) { await _roleplays.SetDedicatedChannelWritabilityForUserAsync ( dedicatedChannel, this.Context.User, true ); await _roleplays.SetDedicatedChannelVisibilityForUserAsync ( dedicatedChannel, this.Context.User, true ); } } var roleplayOwnerUser = await this.Context.Guild.GetUserAsync((ulong)roleplay.Owner.DiscordID); await _feedback.SendConfirmationAsync(this.Context, $"Joined {roleplayOwnerUser.Mention}'s roleplay \"{roleplay.Name}\""); }