I've done all the steps required in heroku to setup a discord bot but i need dependency "discord.js fs". How could i accomplish this?
2019-11-27T15:54:52.648918+00:00 app[Worker.1]: [ws] [connection] Clearing heartbeat interval
2019-11-27T15:54:52.649526+00:00 app[Worker.1]: [ws] [connection] Attempted to destroy WebSocket but no connection exists!
2019-11-27T15:54:52.652133+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
2019-11-27T15:54:52.652137+00:00 app[Worker.1]: at WebSocketConnection.<anonymous> (/app/node_modules/discord.js/src/client/ClientManager.js:48:41)
2019-11-27T15:54:52.652139+00:00 app[Worker.1]: at Object.onceWrapper (events.js:300:26)
2019-11-27T15:54:52.652141+00:00 app[Worker.1]: at WebSocketConnection.emit (events.js:210:5)
2019-11-27T15:54:52.652143+00:00 app[Worker.1]: at WebSocketConnection.onClose (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:390:10)
2019-11-27T15:54:52.652145+00:00 app[Worker.1]: at WebSocket.onClose (/app/node_modules/ws/lib/event-target.js:124:16)
2019-11-27T15:54:52.652147+00:00 app[Worker.1]: at WebSocket.emit (events.js:210:5)
2019-11-27T15:54:52.652149+00:00 app[Worker.1]: at WebSocket.emitClose (/app/node_modules/ws/lib/websocket.js:191:10)
2019-11-27T15:54:52.652152+00:00 app[Worker.1]: at TLSSocket.socketOnClose (/app/node_modules/ws/lib/websocket.js:850:15)
2019-11-27T15:54:52.652154+00:00 app[Worker.1]: at TLSSocket.emit (events.js:215:7)
2019-11-27T15:54:52.652156+00:00 app[Worker.1]: at net.js:659:12
2019-11-27T15:54:52.652282+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
2019-11-27T15:54:52.652407+00:00 app[Worker.1]: (node:4) [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.
2019-11-27T15:54:52.721072+00:00 heroku[Worker.1]: Process exited with status 0```
Related
Code:
mongoose.connect('mongodb://localhost:27017/blog'), {
useUnifiedTopology: true,
useNewUrlParser: true,
}
console.log('MongoDB connected successfully!!');
output:
MongoDB connected successfully!!
(node:2868) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at NativeConnection.Connection.openUri (C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\connection.js:824:32)
at C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\index.js:381:10
at C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
at new Promise (<anonymous>)
at promiseOrCallback (C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
at Mongoose._promiseOrCallback (C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\index.js:1234:10)
at Mongoose.connect (C:\Users\v\Desktop\News Blog\node_modules\mongoose\lib\index.js:380:20)
at Object.<anonymous> (C:\Users\v\Desktop\News Blog\server.js:7:10)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2868) [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.
I am having this error popped up whenever I try to connect to my mongo Server from mongoose.
I have also tried using different port numbers and deleting the DB file and recreating it. But still the same error log
terminal output
UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at NativeConnection.Connection.openUri (/home/Desktop/CRUDJS/node_modules/mongoose/lib/connection.js:797:32)
at /home/Desktop/CRUDJS/node_modules/mongoose/lib/index.js:332:10
at /home/Desktop/CRUDJS/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
at new Promise (<anonymous>)
at promiseOrCallback (/home/Desktop/CRUDJS/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/home/Desktop/CRUDJS/node_modules/mongoose/lib/index.js:1153:10)
at Mongoose.connect (/home/Desktop/CRUDJS/node_modules/mongoose/lib/index.js:331:20)
at Object.<anonymous> (/home/Desktop/CRUDJS/app.js:7:10)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
(node:44838) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:44838) [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.
When I have done everything correctly and have scripted correctly the comes up when i put node . in command prompt I even have a valid token!! ::
(node:8744) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided. at Client.login (C:\Users\User\Documents\GitHub TigerDuo\TigerDuo\node_modules\discord.js\src\client\Client.js:204:52) at Object.<anonymous> (C:\Users\User\Documents\GitHub TigerDuo\TigerDuo\index.js:47:5) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 (node:8744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:8744) [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.
and this is my script let alone i have setup heroku and github:
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'MyNeverToBeSharedToken';
bot.on('ready', () => {
console.log('Online.')
bot.user.setActivity('the Tiger Duo server!', {
type: "WATCHING"
})
bot.login(process.env.token);
Try installing dotenv package
require("dotenv").config()
And add this to the top of your code
function checkForChanges() {
let spreadsheetId = '1oHNELBZ3zV4PQBVsJrtqX4Cz00IFmJG_2SaJ4bgTa3c'
let ranges = ['A2:P2', 'A3:P3', 'A4:P4', 'A5:P5']
this.batchGet ({
spreadsheetId,
ranges,
}, (err, result) => {
if (err) {
console.log(err);
} else {
console.log(`${result.valueRanges.length} ranges retrieved.`);
}
})
}
client.on('ready', () => {
while (true) {
checkForChanges();
}
});
I'm expecting that when I change something on the spreadsheet that it returns in console with what was changed. but instead I get this error when i run the program:
[nodemon] starting `node --inspect turnip_bot.js`
Debugger listening on ws://127.0.0.1:9229/b52c6ec8-70cb-451a-9b70-fc8bada920fc
For help, see: https://nodejs.org/en/docs/inspector
(node:1200) UnhandledPromiseRejectionWarning: TypeError: this.batchGet is not a function
at checkForChanges (D:\Programing\Node.js\Discord-Turnip-Bot\turnip_bot.js:72:7)
at Client.<anonymous> (D:\Programing\Node.js\Discord-Turnip-Bot\turnip_bot.js:87:3)
at Client.emit (events.js:323:22)
at WebSocketManager.triggerClientReady (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:433:17)
at WebSocketManager.checkShardsReady (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:417:10)
at WebSocketShard.<anonymous> (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:199:14)
at WebSocketShard.emit (events.js:311:20)
at WebSocketShard.checkReady (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:466:12)
at WebSocketShard.onPacket (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:438:16)
at WebSocketShard.onMessage (D:\Programing\Node.js\Discord-Turnip-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
(node:1200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1200) [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.
I took the code off of the google sheets API quickstart and edited it slightly for my use case and used some of the documentation to help with reading the spreadsheet on mutiple rows.
If I run the sample it returns:
[nodemon] starting `node --inspect google_sheets_api_sample.js`
Debugger listening on ws://127.0.0.1:9229/04ef1aed-3c10-40e5-b8f2-78782b5537bc
For help, see: https://nodejs.org/en/docs/inspector
(node:3208) UnhandledPromiseRejectionWarning: Error: authentication failed
at authorize (D:\Programing\Node.js\Discord-Turnip-Bot\google_sheets_api_sample.js:57:11)
at main (D:\Programing\Node.js\Discord-Turnip-Bot\google_sheets_api_sample.js:13:28)
at Object.<anonymous> (D:\Programing\Node.js\Discord-Turnip-Bot\google_sheets_api_sample.js:42:1)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
(node:3208) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:3208) [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.
[nodemon] clean exit - waiting for changes before restart
I am trying to host a bot on heroku (written using node and discord js). The bot itself is working since I can run it locally with no issues but heroku doesn't seem to like it. I've been getting the same error every time I tried to deploy it. I've changed the Procfile file to a worker instead of web application, I have pushed everything + restarted but can't seem to get it to work. Any help?
2020-01-28T11:31:46.007810+00:00 heroku[worker.1]: State changed from crashed to starting
2020-01-28T11:31:48.995011+00:00 heroku[worker.1]: Starting process with command `node index.js`
2020-01-28T11:31:49.818228+00:00 heroku[worker.1]: State changed from starting to up
2020-01-28T11:31:52.030152+00:00 heroku[worker.1]: State changed from up to crashed
2020-01-28T11:31:52.006456+00:00 heroku[worker.1]: Process exited with status 0
2020-01-28T11:31:51.886594+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Error: An invalid token was provided.
2020-01-28T11:31:51.886618+00:00 app[worker.1]: at /app/node_modules/discord.js/src/client/rest/RESTMethods.js:34:54
2020-01-28T11:31:51.886621+00:00 app[worker.1]: at new Promise (<anonymous>)
2020-01-28T11:31:51.886623+00:00 app[worker.1]: at RESTMethods.login (/app/node_modules/discord.js/src/client/rest/RESTMethods.js:33:12)
2020-01-28T11:31:51.886625+00:00 app[worker.1]: at Client.login (/app/node_modules/discord.js/src/client/Client.js:280:30)
2020-01-28T11:31:51.886627+00:00 app[worker.1]: at Object.<anonymous> (/app/index.js:45:8)
2020-01-28T11:31:51.886629+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:955:30)
2020-01-28T11:31:51.886631+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
2020-01-28T11:31:51.886633+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:811:32)
2020-01-28T11:31:51.886635+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:723:14)
2020-01-28T11:31:51.886637+00:00 app[worker.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
2020-01-28T11:31:51.887556+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
2020-01-28T11:31:51.887666+00:00 app[worker.1]: (node:4) [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.
With just the error it is hard to know the exact problem, but I think that you might have given a wrong Token for the bot, check if you didn't ignore the file containing the token.
If you are using a .env file for your token, then you can define environment variables on the app on Heroku.