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

feat!: add ChannelManager#createMessage() #10559

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TAEMBO
Copy link
Contributor

@TAEMBO TAEMBO commented Oct 16, 2024

Please describe the changes this PR makes and why it should be merged:
Adds a centralized spot where the creation of messages go through.

BREAKING CHANGE: MessageCreateOptions no longer accepts reply. Use messageReference instead.
BREAKING CHANGE: UserManager#send() no longer exists. Use ChannelManager#createMessage() instead.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

@TAEMBO TAEMBO requested a review from a team as a code owner October 16, 2024 06:38
Copy link

vercel bot commented Oct 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 10:30pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 10:30pm

@almostSouji

This comment was marked as outdated.

Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing an implementation in send(). Just like reply is an option there, there should be a forward option.

Although, now that both reply and forward is there, maybe both should be removed in favour of messageReference so we don't have to keep adding new message reference types (and thus new properties).

packages/discord.js/src/structures/Message.js Outdated Show resolved Hide resolved
@Jiralite Jiralite added this to the discord.js 14.17 milestone Oct 16, 2024
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from a55e642 to 1156836 Compare October 17, 2024 03:39
@TAEMBO TAEMBO requested a review from Jiralite October 17, 2024 03:44
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch 6 times, most recently from 7ae23ed to 6f08f65 Compare October 24, 2024 20:41
@TAEMBO TAEMBO changed the title feat: forwarding messages feat!: forwarding messages Oct 24, 2024
packages/discord.js/typings/index.d.ts Show resolved Hide resolved
packages/discord.js/typings/index.d.ts Outdated Show resolved Hide resolved
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from 6f08f65 to afbbc7d Compare November 29, 2024 17:55
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from 715fdbe to bf2ac31 Compare December 5, 2024 21:38
@TAEMBO TAEMBO changed the title feat!: forwarding messages feat!: add ChannelManager#createMessage() Dec 5, 2024
@TAEMBO TAEMBO requested a review from vladfrangu December 5, 2024 21:40
@Jiralite Jiralite dismissed stale reviews from vladfrangu and themself December 16, 2024 14:19

Stale.

Comment on lines 104 to 108
async send(user, options) {
return (await this.createDM(user)).send(options);
const dmChannel = await this.createDM(user);

return this.client.channels.createMessage(dmChannel, options);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed, as it is now located on the more-appropriate channel manager? It only came into existence to allow sending messages to uncached users: #7087

This isn't an actual API route for users, so I would like to say removing this here makes sense. Thoughts, @vladfrangu?

packages/discord.js/src/structures/BaseChannel.js Outdated Show resolved Hide resolved
Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a huge fan of client.channels.createMessage, but not a fan of removing TextBasedChannel#send / Message#reply. Let's please keep those in and redirect to the manager function

@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from bf2ac31 to 6625b32 Compare December 20, 2024 22:10
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from 6625b32 to a320a45 Compare December 20, 2024 22:30
* @param {string|MessagePayload|MessageCreateOptions} options The options to provide
* @returns {Promise<Message>}
*/
async send(user, options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm...torn, it doesn't hurt to have this but I understand why we'd also remove it. 🤷

@discordjs/core do we keep it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a method for users. It should still be on the guild member and user class as a helper, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

5 participants