private async Task ArchiveRoleplayAsync(SocketGuild guild, Roleplay roleplay) { if (roleplay.DedicatedChannelID is null) { return; } if (roleplay.IsPublic) { await PostArchivedRoleplayAsync(guild, roleplay); } var dedicatedChannel = guild.GetTextChannel((ulong)roleplay.DedicatedChannelID); if (dedicatedChannel is null) { return; } // Ensure the messages are all caught up foreach (var message in await dedicatedChannel.GetMessagesAsync().FlattenAsync()) { // We don't care about the results here. await _roleplays.AddToOrUpdateMessageInRoleplayAsync(roleplay, message); } await _roleplays.DeleteDedicatedRoleplayChannelAsync(guild, roleplay); }
public async Task DeleteRoleplayAsync ( [NotNull] [RequireEntityOwnerOrPermission(typeof(DeleteRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var deletionResult = await _roleplays.DeleteRoleplayAsync(roleplay); if (!deletionResult.IsSuccess) { await _feedback.SendErrorAsync(this.Context, deletionResult.ErrorReason); return; } if (!(roleplay.DedicatedChannelID is null)) { var deleteDedicatedChannelResult = await _roleplays.DeleteDedicatedRoleplayChannelAsync ( this.Context.Guild, roleplay ); if (!deleteDedicatedChannelResult.IsSuccess) { await _feedback.SendErrorAsync(this.Context, deleteDedicatedChannelResult.ErrorReason); return; } } var canReplyInChannelAfterDeletion = (long)this.Context.Channel.Id != roleplay.DedicatedChannelID; if (canReplyInChannelAfterDeletion) { await _feedback.SendConfirmationAsync(this.Context, $"Roleplay \"{roleplay.Name}\" deleted."); } else { var eb = _feedback.CreateEmbedBase(); eb.WithDescription($"Roleplay \"{roleplay.Name}\" deleted."); await _feedback.SendPrivateEmbedAsync(this.Context, this.Context.User, eb.Build(), false); } }