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

fix(TextBasedChannel): allow passing an APIMessage with split #5815

Merged
merged 2 commits into from Jun 11, 2021
Merged

fix(TextBasedChannel): allow passing an APIMessage with split #5815

merged 2 commits into from Jun 11, 2021

Conversation

almeidx
Copy link
Member

@almeidx almeidx commented Jun 11, 2021

Please describe the changes this PR makes and why it should be merged:
Previously, replying to a message (or passing an APIMessage to a TextBasedChannel#send) with split enabled threw a DiscordAPIError: Invalid Form Body.

Example:

message.reply({ content: '<message content>', split: true });

Error:

DiscordAPIError: Invalid Form Body
content: Could not interpret "['```\n<message content>\n```']" as string.

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

Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

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

There is another occurrence of this pattern in webhook, can you include that fix there too?

if (options instanceof APIMessage) {
apiMessage = options.resolveData();
} else {
apiMessage = APIMessage.create(this, options).resolveData();
if (Array.isArray(apiMessage.data.content)) {
return Promise.all(apiMessage.split().map(this.send.bind(this)));
}
}

@iCrawl iCrawl merged commit 93b0a4e into discordjs:master Jun 11, 2021
@almeidx almeidx deleted the channel-send-split-fix branch June 11, 2021 22:07
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants