public async Task <RuntimeResult> SetRoleplayNameAsync ( string newRoleplayName, [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var result = await _discordRoleplays.SetRoleplayNameAsync ( roleplay, newRoleplayName ); if (!result.IsSuccess) { return(result.ToRuntimeResult()); } var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!getDedicatedChannelResult.IsSuccess) { return(RuntimeCommandResult.FromSuccess("Roleplay name set.")); } var dedicatedChannel = getDedicatedChannelResult.Entity; await dedicatedChannel.ModifyAsync(p => p.Name = $"{roleplay.Name}-rp"); return(RuntimeCommandResult.FromSuccess("Roleplay name set.")); }
public async Task SetRoleplayNameAsync ( string newRoleplayName, [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var result = await _discordRoleplays.SetRoleplayNameAsync ( roleplay, newRoleplayName ); if (!result.IsSuccess) { await _feedback.SendErrorAsync(this.Context, result.ErrorReason); return; } var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( 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 ShowOrCreateDedicatedRoleplayChannel ( [RequireEntityOwnerOrPermission(typeof(StartStopRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (getDedicatedChannelResult.IsSuccess) { var existingDedicatedChannel = getDedicatedChannelResult.Entity; var message = $"\"{roleplay.Name}\" has a dedicated channel at " + $"{MentionUtils.MentionChannel(existingDedicatedChannel.Id)}"; await _feedback.SendConfirmationAsync(this.Context, message); return; } await _feedback.SendConfirmationAsync(this.Context, "Setting up dedicated channel..."); // The roleplay either doesn't have a channel, or the one it has has been deleted or is otherwise invalid. var result = await _dedicatedChannels.CreateDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!result.IsSuccess) { await _feedback.SendErrorAsync(this.Context, result.ErrorReason); return; } var dedicatedChannel = result.Entity; await _feedback.SendConfirmationAsync ( this.Context, $"All done! Your roleplay now has a dedicated channel at {MentionUtils.MentionChannel(dedicatedChannel.Id)}." ); if (roleplay.IsActive && roleplay.ActiveChannelID != (long)dedicatedChannel.Id) { await StopRoleplayAsync(roleplay); await StartRoleplayAsync(roleplay); } }
public async Task <RuntimeResult> ShowOrCreateDedicatedRoleplayChannel ( [RequireEntityOwnerOrPermission(typeof(StartStopRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (getDedicatedChannelResult.IsSuccess) { var existingDedicatedChannel = getDedicatedChannelResult.Entity; var message = $"\"{roleplay.Name}\" has a dedicated channel at " + $"{MentionUtils.MentionChannel(existingDedicatedChannel.Id)}"; return(RuntimeCommandResult.FromSuccess(message)); } await _feedback.SendConfirmationAsync(this.Context, "Setting up dedicated channel..."); // The roleplay either doesn't have a channel, or the one it has has been deleted or is otherwise invalid. var result = await _dedicatedChannels.CreateDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!result.IsSuccess) { return(result.ToRuntimeResult()); } var dedicatedChannel = result.Entity; if (!roleplay.IsActive || roleplay.ActiveChannelID == (long)dedicatedChannel.Id) { return(RuntimeCommandResult.FromSuccess ( $"All done! Your roleplay now has a dedicated channel at " + $"{MentionUtils.MentionChannel(dedicatedChannel.Id)}." )); } var stopResult = await StopRoleplayAsync(roleplay); if (!stopResult.IsSuccess) { return(stopResult); } var startResult = await StartRoleplayAsync(roleplay); if (!startResult.IsSuccess) { return(startResult); } return(RuntimeCommandResult.FromSuccess ( $"All done! Your roleplay now has a dedicated channel at " + $"{MentionUtils.MentionChannel(dedicatedChannel.Id)}." )); }