I'm having some difficulty getting a discord bot to work
Firstly, in the client.login field, it doesn't recognize my token unless I actually type it into the file itself, it doesn't work if I try to put it as a secret.
Secondly, I'm having trouble inviting it to a server because it needs a redirect uri, but I don't know what I should use as a redirect uri? Would definitely appreciate some help
I'm gonna go ahead and assume this is Discord.js based.
As for the token - are you using
process.env["TOKEN"] with a secret named "TOKEN" in client.login?
And as for inviting the bot, open
https://discord.com/api/oauth2/authorize?client_id=[CLIENTID]&permissions=8&scope=bot in a new tab, but replace [CLIENTID] with your bot's client id (which you can find in the OAuth2 section of the developer portal). This will allow you to invite the bot to a server, and it'll give the bot administrator priviledges. (note: you need the manage servers role in order to invite bots to a server)
@cnnrde Well, I tried lots of things. I named the secret 'soso_key' for reasons...
At first it was client.login('SOSO_KEY), then I changed it to something closer to what you suggested with client.login(process.env['SOSO_KEY']), and then changed the name of it to 'token' to see if maybe the name was the issue. Nothing worked so far. Only one that does is client.login('(the actual bot token)')
@cnnrde ...Weird, I definitely remember trying that one before.
I just copied and pasted that into the file and ran it. For whatever reason, it worked this time. Maybe there was some error happening with the way it was typed or something.
Okay, on to the next issue: The bot is currently running and logged into my server, but it is not responding to the command I programmed it to reply to ("!soso"). Is it usual for bots running on repl.it to take long to reply, or is there something else I need to fix?
@Andre1070 I think you may be using an old Discord.js tutorial. The latest version is v13, and your code looks to be using
client.on('message', ...) which needs to be changed to
client.on('messageCreate', ...) for Discord.js v13. Replit normally runs message events close to instantly. If you're looking for a Discord.js guide, I recommend this one, however be aware it does use some advanced features such as slash commands.