zaida04 / guilded.js

A library for creating bots with the guilded.gg bot API.
https://guilded.js.org
MIT License
69 stars 15 forks source link

Embeds don't send #91

Closed JMTK closed 2 years ago

JMTK commented 2 years ago

Describe the bug When trying to send an embed, I get an error:

Error: [GuildedAPIError:400:POST] /channels/84e7a9e2-b595-493e-9a39-18ed347b92a8/messages - data must have required property 'content', data must have required property 'embeds', data must match a schema

To Reproduce Steps to reproduce the behavior:

var obj = {
    embeds: [{title: 'Test'}]
};
message.reply(obj);

Expected behavior Should send the embed as expected

Screenshots I believe the issue originates from the compiled version of Message.js

/** Send a message that replies to this message. It mentions the user who sent this message. */
reply(content) {
    var _a;
    if (typeof content === "string")
        content = { content };
    return this.client.messages.send(this.channelId, { content: content.content, replyMessageIds: (_a = content.replyMessageIds) !== null && _a !== void 0 ? _a : [this.id] });
}

This compiled version does not spread the properties as denoted in the .ts file:

/** Send a message that replies to this message. It mentions the user who sent this message. */
    reply(content: RESTPostChannelMessagesBody | string) {
        return this.client.messages.send(
            this.channelId,
            typeof content !== "string"
                ? {
                      ...content,
                      replyMessageIds: content.replyMessageIds ? [this.id, ...content.replyMessageIds] : [this.id],
                  }
                : content,
        );
    }

Please complete the following information

Additional context Add any other context about the problem here.

zaida04 commented 2 years ago

Great catch! We actually solved this in #87, however we only had a release for this last night. This has landed in version 0.8.0!

JMTK commented 2 years ago

Ah I missed that! Thank you!