Skip to content

Commit

Permalink
build: v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
liy77 committed Feb 13, 2024
1 parent 6af0a91 commit b778b71
Show file tree
Hide file tree
Showing 4 changed files with 912 additions and 2,260 deletions.
5 changes: 3 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@darkcord/utils",
"description": "util functions for darkcord library",
"version": "0.1.1",
"version": "0.1.2",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"typings": "./dist/index.d.ts",
Expand All @@ -19,6 +19,7 @@
"directory": "packages/utils"
},
"dependencies": {
"discord-api-types": "^0.37.33"
"discord-api-types": "^0.37.33",
"undici": "^5.19.1"
}
}
9 changes: 5 additions & 4 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @ts-ignore
import { KeysToCamelCase, MessageAttachment } from "darkcord";
import { APIInteractionResponse } from "discord-api-types/v10";
import { Buffer } from "node:buffer";
import { Buffer, Blob } from "node:buffer";
import { readFileSync } from "node:fs";
import { MakeErrorOptions, MessagePostData } from "./types";
import { fetch, FormData } from "undici";

export * from "./errors";
export * from "./types";
Expand Down Expand Up @@ -136,13 +137,13 @@ export async function buildAttachment(
return attachment;
}

const blob = await fetch(attachment.file.toString()).then((res) =>
res.blob(),
const buffer = await fetch(attachment.file.toString()).then((res) =>
res.arrayBuffer(),
);

return {
name: attachment.name,
file: blob,
file: Buffer.from(buffer),
description: attachment.description,
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RESTPostAPIChannelMessageJSONBody } from "discord-api-types/v10";
import { Buffer, Blob } from "node:buffer";

export interface MessageAttachment {
name: string;
Expand Down
Loading

0 comments on commit b778b71

Please sign in to comment.