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.

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 Jan 14, 2025 6:12am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 6:12am

@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.

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 2 times, most recently from 6625b32 to a320a45 Compare December 20, 2024 22:30
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch 2 times, most recently from 62ade39 to 21c724f Compare January 1, 2025 21:47
Comment on lines -6503 to -6480
| User
| GuildMember
Copy link
Member

Choose a reason for hiding this comment

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

Aren't this still valid now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because the target when sending a DM is now ChannelManager rather than a User or GuildMember. User#send() and GuildMember#send() now resolve the DM channel and call ChannelManager#createMessage() as opposed to using TextBasedChannel#send() and having that resolve the DM channel from the target.

@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from 21c724f to 12660cd Compare January 3, 2025 23:53
@almeidx almeidx requested review from Jiralite and Qjuh January 4, 2025 17:05
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from 12660cd to fdd6fd7 Compare January 4, 2025 22:21
@GabuTheDev
Copy link

Hello! Not an expert here, but since this PR implements message#forward, the behavior of message#editable and message#edit should also be updated, as forwarded messages cannot be edited.

failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
},
});
}
return this.channel.send(data);
return this.client.channels.createMessage(this.channelId, data);
Copy link
Member

Choose a reason for hiding this comment

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

Target must (currently?) be something with a client, which a string isn't.
e.g. this.target.client.options.failIfNotExists would throw an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The channel ID isn't used as the target though. When using ChannelManager#createMessage(), the ChannelManager is the target, which does have a client property.

https://github.com/discordjs/discord.js/pull/10559/files#diff-0df9d32ad690588a2c0666ab3aeb1f592ab7dc3e27e6161442a3d048d83646cbR166

@TAEMBO
Copy link
Contributor Author

TAEMBO commented Jan 14, 2025

Hello! Not an expert here, but since this PR implements message#forward, the behavior of message#editable and message#edit should also be updated, as forwarded messages cannot be edited.

@GabuTheDev I think updating Message#editable to reflect this limitation is a good idea, however I disagree about updating Message#edit(). That method does not have any existing checks within it as Message#editable exists to serve that purpose.

@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch 2 times, most recently from 8f42fbe to ccab161 Compare January 14, 2025 06:11
@TAEMBO TAEMBO force-pushed the feat/forwarding-messages branch from ccab161 to fdc38c6 Compare January 14, 2025 06:12
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.

8 participants