-
-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message interface declutter & mention / component abstraction #1835
Conversation
@DV8FromTheWorld would be good if you could comment on the task items. |
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class MessageComponents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets group the getters in this file by the types. (Buttons with buttons, Menus with menus)
This will also need to address mentions in slash command interactions. Options of type STRING can contain mentions, which are resolved by discord. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arynxd you still working on this?
this.jda = jda; | ||
this.guild = guild; | ||
|
||
this.users = Collections.unmodifiableList(processMentions(Message.MentionType.USER, new ArrayList<>(), true, this::matchUser)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wrap a lot of collections returned by processMentions()
with a Collections.unmodifiableList()
call.
Maybe change the methods returned collection.
this.users = Collections.unmodifiableList(processMentions(Message.MentionType.USER, new ArrayList<>(), true, this::matchUser)); | |
this.users = processMentions(Message.MentionType.USER, new ArrayList<>(), true, this::matchUser); |
} | ||
catch (NumberFormatException ignored) {} | ||
} | ||
return collection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return collection; | |
return Collections.unmodifiableList(collection); |
this.roles = Collections.unmodifiableList(processMentions(Message.MentionType.ROLE, new ArrayList<>(), true, this::matchRole)); | ||
this.textChannels = Collections.unmodifiableList(processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.TEXT, TextChannel.class))); | ||
this.voiceChannels = Collections.unmodifiableList(processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.VOICE, VoiceChannel.class))); | ||
this.emotes = Collections.unmodifiableList(processMentions(Message.MentionType.EMOTE, new ArrayList<>(), true, this::matchEmote)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.roles = Collections.unmodifiableList(processMentions(Message.MentionType.ROLE, new ArrayList<>(), true, this::matchRole)); | |
this.textChannels = Collections.unmodifiableList(processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.TEXT, TextChannel.class))); | |
this.voiceChannels = Collections.unmodifiableList(processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.VOICE, VoiceChannel.class))); | |
this.emotes = Collections.unmodifiableList(processMentions(Message.MentionType.EMOTE, new ArrayList<>(), true, this::matchEmote)); | |
this.roles = processMentions(Message.MentionType.ROLE, new ArrayList<>(), true, this::matchRole); | |
this.textChannels = processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.TEXT, TextChannel.class)); | |
this.voiceChannels = processMentions(Message.MentionType.CHANNEL, new ArrayList<>(), true, it -> matchChannel(it, ChannelType.VOICE, VoiceChannel.class)); | |
this.emotes = processMentions(Message.MentionType.EMOTE, new ArrayList<>(), true, this::matchEmote); |
|
||
if (guild == null) | ||
{ | ||
this.members = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also wrap this.
this.members = new ArrayList<>(); | |
this.members = Collections.unmodifiableList(new ArrayList<>()); |
Should options of types user, channel, role & mentionable also be included in their respective lists? |
Superseded by #2015 |
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
This PR implements the new message mentions / components abstractions that are planned for v5. It will be draft until the checklist is complete. This is open for contribution.
TODO