snowtransfer
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -52,6 +52,6 @@ /// <reference types="node" /> | ||
* const fileData = fs.readFileSync("nice_emoji.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods pause the thread. | ||
* const emojiData = { | ||
* const emojiData = \{ | ||
* name: "niceEmoji", | ||
* image: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String | ||
* } | ||
* \} | ||
* client.guildAssets.createEmoji("guild id", emojiData) | ||
@@ -58,0 +58,0 @@ */ |
@@ -60,6 +60,6 @@ "use strict"; | ||
* const fileData = fs.readFileSync("nice_emoji.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods pause the thread. | ||
* const emojiData = { | ||
* const emojiData = \{ | ||
* name: "niceEmoji", | ||
* image: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String | ||
* } | ||
* \} | ||
* client.guildAssets.createEmoji("guild id", emojiData) | ||
@@ -66,0 +66,0 @@ */ |
@@ -114,7 +114,7 @@ /** | ||
* const client = new SnowTransfer("TOKEN") | ||
* const channelData = { | ||
* const channelData = \{ | ||
* name: "nice voice channel", | ||
* type: 2, | ||
* permission_overwrites: [{ id: "guild id", type: 0, allow: "0" deny: (BigInt(1) << BigInt(20)).toString() }] | ||
* } | ||
* permission_overwrites: [\{ id: "guild id", type: 0, allow: "0" deny: (BigInt(1) << BigInt(20)).toString() \}] | ||
* \} | ||
* const channel = await client.guild.createGuildChannel("guild id", channelData) | ||
@@ -121,0 +121,0 @@ */ |
@@ -132,7 +132,7 @@ "use strict"; | ||
* const client = new SnowTransfer("TOKEN") | ||
* const channelData = { | ||
* const channelData = \{ | ||
* name: "nice voice channel", | ||
* type: 2, | ||
* permission_overwrites: [{ id: "guild id", type: 0, allow: "0" deny: (BigInt(1) << BigInt(20)).toString() }] | ||
* } | ||
* permission_overwrites: [\{ id: "guild id", type: 0, allow: "0" deny: (BigInt(1) << BigInt(20)).toString() \}] | ||
* \} | ||
* const channel = await client.guild.createGuildChannel("guild id", channelData) | ||
@@ -139,0 +139,0 @@ */ |
@@ -49,5 +49,5 @@ /** | ||
* const fileData = fs.readFileSync("new_avatar.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods may lag your bot. | ||
* const updateData = { | ||
* const updateData = \{ | ||
* avatar: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String | ||
* } | ||
* \} | ||
* client.user.updateSelf(updateData) | ||
@@ -54,0 +54,0 @@ */ |
@@ -58,5 +58,5 @@ "use strict"; | ||
* const fileData = fs.readFileSync("new_avatar.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods may lag your bot. | ||
* const updateData = { | ||
* const updateData = \{ | ||
* avatar: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String | ||
* } | ||
* \} | ||
* client.user.updateSelf(updateData) | ||
@@ -63,0 +63,0 @@ */ |
@@ -11,3 +11,2 @@ /// <reference types="node" /> | ||
constructor(path: string, error: any, method: HTTPMethod, status: number); | ||
static flattenErrors(obj: Record<string, any>, key?: string): string[]; | ||
} | ||
@@ -14,0 +13,0 @@ interface HandlerEvents { |
@@ -17,5 +17,4 @@ "use strict"; | ||
super(); | ||
const flattened = DiscordAPIError.flattenErrors(error.errors || error).join("\n"); | ||
this.name = "DiscordAPIError"; | ||
this.message = error.message && flattened ? `${error.message}\n${flattened}` : error.message || flattened; | ||
this.message = error.message || String(error); | ||
this.method = method; | ||
@@ -26,19 +25,2 @@ this.path = path; | ||
} | ||
static flattenErrors(obj, key = "") { | ||
let messages = []; | ||
for (const [k, v] of Object.entries(obj)) { | ||
if (k === "message") | ||
continue; | ||
const newKey = key ? (isNaN(Number(k)) ? `${key}.${k}` : `${key}[${k}]`) : k; | ||
if (v._errors) | ||
messages.push(`${newKey}: ${v._errors.map(e => e.message).join(" ")}`); | ||
else if (v.code || v.message) | ||
messages.push(`${v.code ? `${v.code}: ` : ""}${v.message}`.trim()); | ||
else if (typeof v === "string") | ||
messages.push(v); | ||
else | ||
messages = messages.concat(this.flattenErrors(v, newKey)); | ||
} | ||
return messages; | ||
} | ||
} | ||
@@ -45,0 +27,0 @@ /** |
{ | ||
"name": "snowtransfer", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "Minimalistic Rest client for the Discord Api", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.js", | ||
"centra": "^2.5.0", | ||
"discord-typings": "^10.1.2", | ||
"discord-typings": "^10.3.0", | ||
"form-data": "~4.0.0" | ||
@@ -39,10 +39,10 @@ }, | ||
"@types/centra": "^2.2.0", | ||
"@types/node": "^16.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.21.0", | ||
"@typescript-eslint/parser": "^5.21.0", | ||
"eslint": "^8.14.0", | ||
"typedoc": "^0.22.15", | ||
"typedoc-plugin-mdn-links": "^1.0.6", | ||
"typedoc-plugin-missing-exports": "^0.22.6", | ||
"typescript": "^4.6.3" | ||
"@types/node": "^18.6.5", | ||
"@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"@typescript-eslint/parser": "^5.33.0", | ||
"eslint": "^8.21.0", | ||
"typedoc": "^0.23.10", | ||
"typedoc-plugin-mdn-links": "^2.0.0", | ||
"typedoc-plugin-missing-exports": "^0.23.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
@@ -49,0 +49,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
372446
7333
Updateddiscord-typings@^10.3.0