skip to Main Content

it keeps saying Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/gamingboikid/discordbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26)
at Client.login (/home/gamingboikid/discordbot/node_modules/discord.js/src/client/Client.js:223:21) {
[Symbol(code)]: ‘TOKEN_INVALID’
} .

how do i get rid of it and this is my code


const { Client, Collection, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_VOICE_STATES] });

client.once("ready", (c) => {
console.log(`Ready, Logged in as d`);
});

try {
    client.login("");
} catch (error) {
    console.log(error)
}

i will not show my token

new coding but still didnt work

2

Answers


  1. There is nothing wrong with your code, you just need to reset your Discord bot token so you can obtain a new token. Go to https://discord.com/developers/applications, select your bot, go to the Bot section, click on "Reset Token", and then "Yes, do it!".

    client.login('Your new bot token goes here');
    
    Login or Signup to reply.
  2. Please make sure to insert the bot token in "":

    client.login("INSERT TOKEN HERE")

    You can get the client token of the bot by going to https://discord.com/developers/applications then selecting your application, and adding a bot through the Bot tab. Copy the Token of the bot, and paste it in the INSERT TOKEN HERE

    Your new code:

    const { Client, Collection, Intents } = require('discord.js');
    
    const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_VOICE_STATES] });
    
    client.once("ready", (c) => {
    console.log(`Ready, Logged in as d`);
    });
    
    try {
        client.login("TOKEN HERE");
    } catch (error) {
        console.log(error)
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search