Skip to content

Commit

Permalink
v1.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
itzTheMeow committed Sep 30, 2023
1 parent ab10d4e commit 1f63f13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.1.11

- Fix message payload construction of `embed`.

v1.1.10

- Added tag support for autocomplete.
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "revkit",
"version": "1.1.10",
"version": "1.1.11",
"description": "An alternative to revolt.js that aims to be familiar to use.",
"main": "dist/cjs/index.js",
"module": "dist/es6/index.js",
Expand Down
11 changes: 10 additions & 1 deletion core/src/utils/Messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@ export function constructMessagePayload(data: MessagePayload, channel?: Channel)
nonce: ulid(),
};

// if an Embed is passed, set the `embeds` option to that embed
if (data instanceof Embed) {
opts.embeds = [data.toJSON()];
} else {
// if an object is passed
if (typeof data !== "string") {
if (data.embed) data.embeds = [data.embed, ...(data.embeds || [])];
// move `embed` into the `embeds` array
if (data.embed) {
data.embeds = [data.embed, ...(data.embeds || [])];
delete data.embed;
}
// deconstruct any Embeds into JSON
if (data.embeds) data.embeds = data.embeds.map((e) => (e instanceof Embed ? e.toJSON() : e));
// omit the type so ts doesnt yell at us about Embed classes
opts = { ...opts, ...(<Omit<typeof data, "embeds">>data) };
}
// set content to passed string or object prop
opts.content = typeof data == "string" ? data : data.content;
if (channel) {
if (
Expand Down

0 comments on commit 1f63f13

Please sign in to comment.