public async Task <RuntimeResult> ResetChannelPermissionsAsync()
        {
            await _feedback.SendConfirmationAsync(this.Context, "Working...");

            var getRoleplays = await _discordRoleplays.GetRoleplaysAsync(this.Context.Guild);

            if (!getRoleplays.IsSuccess)
            {
                return(getRoleplays.ToRuntimeResult());
            }

            var roleplays = getRoleplays.Entity.ToList();

            foreach (var roleplay in roleplays)
            {
                if (!roleplay.DedicatedChannelID.HasValue)
                {
                    continue;
                }

                var reset = await _dedicatedChannels.ResetChannelPermissionsAsync(this.Context.Guild, roleplay);

                if (!reset.IsSuccess)
                {
                    await _feedback.SendErrorAsync(this.Context, reset.ErrorReason);
                }
            }

            return(RuntimeCommandResult.FromSuccess("Permissions reset."));
        }
Example #2
0
        public async Task ResetChannelPermissionsAsync()
        {
            await _feedback.SendConfirmationAsync(this.Context, "Working...");

            var getRoleplays = await _discordRoleplays.GetRoleplaysAsync(this.Context.Guild);

            if (!getRoleplays.IsSuccess)
            {
                await _feedback.SendErrorAsync(this.Context, getRoleplays.ErrorReason);

                return;
            }

            var roleplays = await getRoleplays.Entity.ToListAsync();

            foreach (var roleplay in roleplays)
            {
                if (!roleplay.DedicatedChannelID.HasValue)
                {
                    continue;
                }

                var reset = await _dedicatedChannels.ResetChannelPermissionsAsync(this.Context.Guild, roleplay);

                if (!reset.IsSuccess)
                {
                    await _feedback.SendErrorAsync(this.Context, reset.ErrorReason);
                }
            }

            await _feedback.SendConfirmationAsync(this.Context, "Permissions reset.");
        }
    public async Task <Result <FeedbackMessage> > ResetChannelPermissionsAsync()
    {
        var roleplays = await _discordRoleplays.QueryRoleplaysAsync
                        (
            q => q
            .Where(rp => rp.Server.DiscordID == _context.GuildID.Value)
            .Where(rp => rp.DedicatedChannelID.HasValue)
                        );

        foreach (var roleplay in roleplays)
        {
            var reset = await _dedicatedChannels.ResetChannelPermissionsAsync(roleplay);

            if (!reset.IsSuccess)
            {
                await _feedback.SendContextualErrorAsync(reset.Error.Message, _context.User.ID);
            }
        }

        return(new FeedbackMessage("Permissions reset.", _feedback.Theme.Secondary));
    }