Skip to content

Add a channel getter in MessageCreateAction #3048

@YvanMazy

Description

@YvanMazy

General Troubleshooting

  • I have checked for similar issues on the Issue-tracker.
  • I have updated to the latest JDA version
  • I have checked the branches or the maintainers' PRs for upcoming features.

Feature Request

Hello,

The MessageCreateAction interface does not provide a method to retrieve the MessageChannel used in the action. Likewise, there is no getter to access stickers or the MessageReference.

Perhaps this is intentional and actions are not meant to expose getters, but MessageCreateAction extends MessageCreateRequest, which does provide getters for attachments, mentions, embeds, components, etc.

It would be really useful to have a method to retrieve the channel, because in my case I’m working with a list of MessageCreateAction instances where I apply setMessageReference() on each one. The issue is that the actions don’t all use the same channel, and setMessageReference() requires the message history permission, which I cannot verify without access to the channel.

At the moment, the simplest workaround for me is to handle a wrapper object that stores both the action reference and the associated channel.

Example Use-Case

MessageCreateAction action = ...;
MessageChannel messageChannel = action.getChannel();
if (messageChannel instanceof GuildMessageChannel guildMessageChannel) {
    if (!selfMember.hasPermission(guildMessageChannel, Permission.MESSAGE_HISTORY)) {
        return;
    }
}
action.setMessageReference(messageId);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions