andersfylling / disgord

Go module for interacting with the documented Discord's bot interface; Gateway, REST requests and voice
BSD 3-Clause "New" or "Revised" License
502 stars 71 forks source link

`channel.SendMsg` doesn't send the `Components` #506

Open henriqueleite42 opened 1 year ago

henriqueleite42 commented 1 year ago

This works:

s.Channel(channel.ID).WithContext(context.Background()).CreateMessage(&disgord.CreateMessage{
    Content: "Foo",
    Components: []*disgord.MessageComponent{
        {
            Type: 1,
            Components: []*disgord.MessageComponent{
                {
                    Type: 2,
                    CustomID: "FOO",
                    Label: "Foo Bar",
                    Style: 4,
                },
            },
        },
    },
})

And this doesn't work:

channel.SendMsg(context.Background(), s, &disgord.Message{
    Content: "Foo",
    Components: []*disgord.MessageComponent{
        {
            Type: 1,
            Components: []*disgord.MessageComponent{
                {
                    Type: 2,
                    CustomID: "FOO",
                    Label: "Foo Bar",
                    Style: 4,
                },
            },
        },
    },
})

My guess is that you need to add Components here, below the line 237: image

In an if like this one:

if len(message.Components) > 0 {
  params.Components = message.Components
}

Another thing, this shouldn't get all the embeds instead of just the first one?

if len(message.Embeds) > 0 {
  params.Embed = message.Embeds[0]
}