Bot not able to login. After starting other sample code, logging in with same token, login possible

Hello there. I'm having a weird problem for a few months now. I also asked here about it an never got it resolved yet. I only found a weird temporary fix now.

So, my bot is starting, but not able to log in. basically all information im getting is in screenshot one.
Now, today i discovered, when im starting a sample bot, like this:
import {Client, GatewayIntentBits} from "discord.js"

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds
    ]
});

client.on("ready", ()=> {
    console.log("debug")
})

client.login(<token>)

it will login, and after that i can start my bot (or rather my code) just fine and it will be able to log in for about 2-3 days. any ideas?
image.png
Was this page helpful?