Skip to content
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

Changes to how sending messages works #5771

Closed
iCrawl opened this issue Jun 6, 2021 · 0 comments · Fixed by #5758
Closed

Changes to how sending messages works #5771

iCrawl opened this issue Jun 6, 2021 · 0 comments · Fixed by #5758

Comments

@iCrawl
Copy link
Member

iCrawl commented Jun 6, 2021

Is your feature request related to a problem? Please describe.

As it currently stands, we have a multitude of different overloads for our .send([content], [options]) methods. Some of which are just confusing and lead to all kinds of problems that are not intended in the first place:

channel.send('Hello World 👋');
channel.send(embed, { embed: embed });
channel.send([embed, embed2]) // ??? Normal messages cannot even consist of two embeds so only the first one is being sent
channel.send([attachment, attachment2]);
channel.send(attachment, { files: [attachment] }); // ???
channel.send(embed, { content: 'Hello World 👋' });
channel.send('Hello World 👋', { embed: embed });

webhook.send('Hello World 👋', { embeds: [embed] });
webhook.send({ embeds: [embed, embed2] });
webhook.send([embed, embed2]); // Here it works because webhooks do allow you to send multiple embeds
webhook.send([attachment, attachment2]);
webhook.send(attachment, { files: [attachment] }); // ???

This gets even more complicated now once we start working with interactions and can send normal messages as we can send webhook messages:

interaction.send('Hello World 👋', { ephemeral: true, embeds: [embed], components: [row] });
interaction.send({ content: 'Hello World 👋', embeds: [embed], components: [row] });
interaction.send(embed, { content: 'Hello World 👋', components: [row] }); // But we can send multiple embeds right?
interaction.send([embed, embed2], { content: 'Hello World 👋', components: [row] }); // I can not 100% confirm, but I would not be surprised if this works

Describe the ideal solution

The ideal solution to this would be to have a nice and conform interface that allows a certain amount of strictness yet enough flexibility to cover the most used use-cases without having a high maintenance cost or confusing syntax:

channel.send('Hello World 👋');
channel.send({ embed: embed }); // For the sake of explicitness, but this can obviously be `{ embed } as a shorthand`
channel.send({ files: [attachment] });
channel.send({ files: [attachment, attachment2] });
channel.send({ content: 'Hello World 👋', embed: embed });

webhook.send('Hello World 👋');
webhook.send({ content: 'Hello World 👋', embeds: [embed] });
webhook.send({ embeds: [embed1, embed2] });
webhook.send({ files: [attachment] });
webhook.send({ files: [attachment, attachment2] });

interaction.send('Hello World 👋');
interaction.send({ content: 'Hello World 👋', embeds: [embed] });
interaction.send({ embeds: [embed] });
interaction.send({ embeds: [embed, embed2] });

Describe alternatives you've considered

I had some thoughts about doing something like allowing:

channel.send(embed);
channel.send(attachment);

While the former is completely in line with how bots can send only one embed to a TextChannel, there is a huge problem with the second one since bots can send multiple attachments.

Going back to how we did it before (as seen in the first code block) is a bit problematic since it is ambiguous, provides too much flexibility and is confusing. It opens a whole assortment of problems as to why we would allow it for embeds on webhooks, but not on TextChannels.

Edit:

I also briefly thought about allowing some spread syntax:

channel.send(attachment, attachment2, ...attachments);

But this would be even worse in terms of usability and UX

It is less of a problem when sending only two attachments, as we can do surely do:

channel.send([attachment, attachment2]);

But the moment you want to add more than just attachments you have to refactor your whole code to:

channel.send({ content: 'Hello World 👋', files: [attachment, attachment2] });

While if we make the changes proposed this would not have to happen, since the only allowed method would be:

channel.send({ files: [attachment, attachment2] });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant