Table of Contents

V3.18

Among the changes in V3.18 was components V2, while splendid, it did bring with it a few changes you should be aware of.

  • IMessage

Messages components type has changed. As a patch you can convert it to an IEnumerable<ActionRowComponent> again like so:

IMessage message = component.Message;
IReadOnlyCollection<IMessageComponent>? components = message.Components;
IEnumerable<ActionRowComponent>? componentsLegacy = components.OfType<ActionRowComponent>();
  • Nested components

The usage of components with ActionRowBuilder and ComponentBuilder has a type change as well. You can find examples in Components_V2_Advanced.

  • Components V2 Flag

To use Components V2 in a message (through ModifyAsync/UpdateAsync/...), a specific flag has to be set. This cannot be undone though :^). You only have to set it if you modify a message that didn't have components v2 in them to begin with (or if you already set the flag manually - obviously). This means that if you created a message with your bot that has components in it, the flag will automatically be set.

Otherwise, you can manually set it like so:

MessageFlags? flags = component.Message.Flags ?? MessageFlags.None;
flags = flags | MessageFlags.ComponentsV2;

await component.UpdateAsync(m => 
        { 
                m.Flags = flags; 
                m.Components = cv2builder.Build();
        });