im using uptimerobot.com to create my first discord bot, but it does not work well. i really dont have no idea to solve this problem. the following picture shows how i use uptimerobot.com
according to the logs, i got errors 5~6 hours ago (above the line)
however, i did not receive any errors 1~4 hours ago. (note that i did not change anything)
This error usually happens when your Discord bot token is invalid. Can you try generating a new Discord token and using it?
although i regenerate my token and paste it env, it could not work well…
plus, no error is in logs
Hey @33333-33333,
Can you provide the project name so that I can take a look? And it would be better to move all your tokens, even commented ones to the .env
file.
url deleted
here is the link of it
Ehhh…the project is set to private! Maybe you can make it public for a while…
sry i made it public
Hey @33333-33333,
The error was caused because a Discord bot token was not provided. And the token was not provide because you referred it in the .env
in a wrong way. To fix the issue, in line 1 of your main.js
, change the statement to:
const TOKEN = process.env.DISCORD_BOT_TOKEN;
because you declared the Discord token as DISCORD_BOT_TOKEN
, not simply TOKEN
in the .env
file.
And make sure you have the following statement at the bottom of your main.js
:
client.login(TOKEN);
That should fix the issue
Happy Glitching!
When I remixed your project, it never stopped loading. The circle will keep on moving next to the Tools button. There might be something wrong with the code.
could you tell me where it is wrong?
for the infinite loading part, add this to the top of bot.js or index.js or wherever the main part of your bot is:
const http = require(‘http’);
const express = require(‘express’);
const app = express();
app.use(express.static(‘public’));
app.get(“/”, (request, response) => {
console.log(Date.now() + " ping received!");
response.sendStatus(200);
// The file “index.html” is being sent to the server, which will be rendered once someone has visited the route/
response.sendFile(__dirname + ‘/public/’);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get(http://[PROJECT NAME HERE].glitch.me/
);
}, 280000);
let me know if that works for the infinitely loading circle part.
What is your discord tag, could you add me, and dm me your project invite link so i could take a look at your errors, and possibly help you?
i know the errors, you gotta replace the pasted '
with a normal ’
ohh. right. I didn’t catch that when i looked at the screenshot above
const http = require("http");
const express = require("express");
const app = express();
app.use(express.static("public"));
app.get("/", (request, response) => {
console.log(Date.now() + " ping received!");
response.sendStatus(200);
// The file “index.html” is being sent to the server, which will be rendered once someone has visited the route "/"
response.sendFile(__dirname + "/public/");
});
app.listen(process.env.PORT);
setInterval(() => {
http.get("http://[PROJECT NAME HERE].glitch.me/" );
}, 280000);
Hey @33333-33333,
This should solve the problem, at least it did for me!
- Add a new package in
package.json
called Express.
So yourpackage.json
should look like this:
{
"name": "glitch-discord-bot",
"version": "0.0.0",
"description": "discord bot sample on Glitch",
"main": "main.js",
"dependencies": {
"discord.js": "^11.5.1",
"express": "^4.16.4"
},
"devDependencies": {},
"scripts": {
"start": "node main.js",
"test": "node main.js"
}
}
- Then at the top of
main.js
, add these few lines:
const http = require("http");
const express = require("express");
const app = express();
app.use(express.static("public"));
app.get("/", (request, response) => {
console.log(Date.now() + " ping received!");
response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get("http://drednot-bot.glitch.me/");
}, 280000);
Thanks to @J-Tech-Foundation and @Verico
hmmmm… what happened to my bot…
Try deleting the bot and creating a new one. It usually happens after when the Uptime Monitor is not working. Or do you see any errors in the logs?
are they errors?
anyway, uptimerobot says that the bot is not down. If i have to make a new bot, could i copy and paste assets? I uploaded a number of pictures to there.
I didn’t mean to delete the Glitch project and create a new one! In Discord, delete the bot you have and create a new one.
it did not change anything :(((
I must admit, this is a very frustrating problem!
Are you sure you entered a token in the .env
file?
By any chance, do you have the following error in your logs?
(node:544) UnhandledPromiseRejectionWarning: Error: Something took too long to do.
at timeout.client.setTimeout (/rbd/pnpm-volume/0be04d99-7540-41f3-96f0-0d16fc82a413/node_modules/.registry.npmjs.org/discord.js/11.5.1/[email protected]/node_modules/discord.js/src/client/ClientManager.js:40:57)
at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/0be04d99-7540-41f3-96f0-0d16fc82a413/node_modules/.registry.npmjs.org/discord.js/11.5.1/[email protected]/node_modules/discord.js/src/client/Client.js:436:7)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
(node:544) 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: 11)
(node:544) [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.
Could you remove SECRET =
and MADE_WITH=
in the .env
file?
Hey @33333-33333,
Maybe you could invite me to your project through a DM?
Your project name is drednot-bot
, am I right?
yeah. i have already invited u. did you find any wrong points?
Errr…from where did you copy the token? Your token looks very suspicious. It might be the Client Secret you have copied? Because usually, Discord tokens are very long!
yeah i used client secret…
This is how you copy the Discord token.
- On the left sidebar of the Discord Developer page of your bot, select Bot.
- Under the heading of Token, you will see a button that says Copy. Click on it.
- Paste it in the
.env
true. i did so. is it correct way to copy the token?
then, why did you say that “Your token looks very suspicious.”?
(i reached the limit of post)
solved :))))
thank you so muchhhhhhh XD
Yes. In fact, this is what’s called the Discord token.
That’s because I thought the Client Secret was actually a Discord Token. Anyways, is it solved?