webhook-discord
webhook-discord copied to clipboard
Error: 400 undefined
I test it on a NextJS project. and I got this every time when I want to use message builder.
Unhandled Runtime Error
Error: 400 undefined
Source
.next\static\chunks\pages\test.js (195:0) @ <unknown>
193 | return res;
194 | } else {
> 195 | const err = new Error(`${res.status} ${res.statusText}`.trim());
196 | Object.assign(err, res);
197 | return Promise.reject(err);
198 | }
@istiaqueahmedarik this should work
const msg = new webhook.MessageBuilder()
.setName('Awesome Bot')
.setTitle('Awesome title')
.setColor('#f1e05a')
.setText(`Awesome text`)
.setURL(`https://google.com`);
Hook.send(msg);
Looks like now must put an embed with a Title. The example at Readme no longer works too:
const msg = new webhook.MessageBuilder()
.setName("Username")
.setColor("#aabbcc")
.setText("This is my webhook!");
Hook.send(msg);
$ node --trace-warnings index.js
This now throws
(node:247015) UnhandledPromiseRejectionWarning: Error: 400 Bad Request
at /home/user/Documents/discord-test/node_modules/snekfetch/src/index.js:195:23
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
(node:247015) Error: 400 Bad Request
at /home/user/Documents/discord-test/node_modules/snekfetch/src/index.js:195:23
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:247015) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:96:32)