Exemplo n.º 1
0
        public async Task ListAutorolesAsync()
        {
            var autoroles = new List <AutoroleConfiguration>();

            foreach (var role in this.Context.Guild.Roles)
            {
                var getAutorole = await _autoroles.GetAutoroleAsync(role);

                if (!getAutorole.IsSuccess)
                {
                    continue;
                }

                autoroles.Add(getAutorole.Entity);
            }

            var pager = PaginatedEmbedFactory.SimpleFieldsFromCollection
                        (
                _feedback,
                _interactivity,
                this.Context.User,
                autoroles,
                at => $"@{this.Context.Guild.Roles.First(r => r.Id == (ulong)at.DiscordRoleID).Name}",
                at => at.IsEnabled ? "Enabled" : "Disabled",
                "There are no autoroles configured."
                        );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                pager,
                TimeSpan.FromMinutes(5)
            );
        }
Exemplo n.º 2
0
    /// <inheritdoc />
    public override async ValueTask <Result <AutoroleConfiguration> > TryParseAsync(string value, CancellationToken ct = default)
    {
        value = value.Trim();

        if (!Snowflake.TryParse(value.Unmention(), out var roleID))
        {
            return(new ParsingError <AutoroleConfiguration>(value));
        }

        var getAutorole = await _autoroles.GetAutoroleAsync(roleID.Value, ct);

        return(!getAutorole.IsSuccess
            ? Result <AutoroleConfiguration> .FromError(getAutorole)
            : getAutorole.Entity);
    }