#Buttons are always disabled

1 messages · Page 1 of 1 (latest)

queen gust
#

I've been trying to make a small bot and I'm having some trouble with the components in a post.

I have the following method generating the components to be passed to CreatePostAsync:

private MessageComponent CreateChoreList()
{
    var messageComponents = new List<IMessageComponentBuilder>
    {
        new TextDisplayBuilder().WithContent("# 📝 As Tuas Tarefas"),
    };

    foreach (var chore in chores)
    {
        var messageContent = new StringBuilder()
            .AppendLine($"## 🔹 {chore.Title}")
            .AppendLine($"**📝 Descrição**: {chore.Description}")
            .AppendLine($"**📅 Criado**: {chore.CreatedAt:g}")
            .AppendLine($"**✏️ Atualizado**: {(chore.UpdatedAt.HasValue ? chore.UpdatedAt.Value.ToString("g") : "Nunca")}");

        var sectionBuilder = new SectionBuilder()
            .WithComponents([new TextDisplayBuilder().WithContent(messageContent.ToString())])
            .WithAccessory(new ButtonBuilder()
            // TODO: Replace with constant
            .WithCustomId($"complete_chore:{chore.Id}")
            .WithStyle(ButtonStyle.Success)
            .WithDisabled(false)
            // TODO: Replace with constant
            .WithEmote(new Emoji("✅"))
            // TODO: Replace with constant
            .WithLabel("Completar Tarefa"));

        messageComponents.Add(new SeparatorBuilder());
        messageComponents.Add(sectionBuilder);
    }

    var containerBuilder = new ContainerBuilder()
        .WithComponents(messageComponents)
        .WithAccentColor(Color.DarkBlue);

    var componentsV2 = new ComponentBuilderV2()
        .AddComponent(containerBuilder);

    return componentsV2.Build();
}

As shown in the picture, it looks as I expected except the buttons are disabled.

My question would be how can I make the buttons work? I'm sure I missed something stupid but I am super new with this library.

uncut citrus
#

CreatePostAsync

#

i don't recall exactly, but there is a quirk with discord itself

#

when the components on a thread starter message are not usable inside the thread (??) or the opposite way

queen gust
#

hmm ok, not sure I'm understanding

#

you're saying that maybe I'm not using the button in the thread itself?

#

and would this be something just for the thread starter?

uncut citrus
#

it's either

components on a thread starter message
not usable in the thread

components on a thread starter message
not usable outside of the thread
one of these is correct

That's the only case where components may get forced to disabled (apart from message forwards)

queen gust
#

ok, so I'll try to make it not the thread starter

#

even when it's not the thread starter I have the same behaviour

#
private static async Task InteractionCreatedAsync(SocketInteraction interaction)
{
    if (interaction is SocketMessageComponent component)
    {
        Match match = Regex.Match(
            component.Data.CustomId,
            @"complete_chore:([0-9A-Fa-f]{8}-?([0-9A-Fa-f]{4}-?){3}[0-9A-Fa-f]{12})$");

        if (match.Success)
        {
            string guidString = match.Groups[1].Value;
            if (Guid.TryParse(guidString, out Guid choreId))
            {
                await interaction.RespondAsync($"Tarefa {choreId} completada.");
            }
            else
            {
                await interaction.RespondAsync("Erro.");
            }
        }
    }
}
#

this is the what I have checking the buttons, sure I'm doing something wrong