Search code examples
pythondiscorddiscord.py

How to solve this "discord.client logging in using static token" error


my code was running perfectly for some time but it stopped suddenly with an unexpected token error and also i tried adding an image to the rich presence of my bot but it doesn't seem to be working and also i did my whole in replit The error!

import discord
from webserver import keep_alive

import os

intents = discord.Intents.all()
client = discord.Client(intents=intents)

welcome_channel = None

prefix = "&"

@client.event
async def on_ready():
    print(f"Logged in as {client.user}!")
    await client.change_presence(status= discord.Status.dnd,
    activity = discord.Activity(type=discord.ActivityType.playing,
    assets={
        'large_text': 'details',
        'large_image': 'https://cdn.discordapp.com/attachments/998612463492812822/1063409897871511602/welcome.png',
    },
    name = "Dynamically",
    details = "Dreams of Desires",
    ))

@client.event
async def on_message(message):
    if message.content.startswith(prefix):
        command = message.content[len(prefix):]

        # Set welcome channel command
        if command.startswith("setwelcomechannel"):
            # Check if the user is an admin
            if not message.author.guild_permissions.administrator:
                await message.channel.send("You have to be an admin to set the welcome channel.")
                return
            # Set the welcome channel
            global welcome_channel
            welcome_channel = message.channel
            await message.channel.send(f"Welcome channel set to {welcome_channel.name}.")

        # Get welcome channel command
        if command.startswith("getwelcomechannel"):
            # Check if the welcome channel has been set
            if welcome_channel is None:
                await message.channel.send("Welcome channel is not set.")
            else:
                await message.channel.send(f"Welcome channel is set to {welcome_channel.name}.")
        # Add your new commands here
        if command.startswith("hello"):
            await message.channel.send("Hii!")
        if command.startswith("dead"):
            await message.channel.send("latom!")

@client.event
async def on_member_join(member):
    # Send the welcome message
    if welcome_channel:
        embed = discord.Embed(title="Welcome!", description=f"Ara ara! {member.mention}, welcome to {member.guild.name}\nHope you find Peace here!", color=0x8438e8)
        embed.set_image(url= 'https://cdn.discordapp.com/attachments/998612463492812822/1063409897871511602/welcome.png')
        await welcome_channel.send(embed=embed)

keep_alive()
TOKEN = os.environ.get("DISCORD_BOT_SECRET")
client. Run(TOKEN)

to run properly and to show an image in the presence.


Solution

  • "discord.client logging in using static token" error

    That says INFO, not ERROR, so it's not an error. The actual error is the red lines underneath, which is caused by you using Replit to run the bot.

    Replit uses the same IP address for every bot, so all Replit bots combined will cause Discord to ratelimit you. The only solution is to use an actual VPS instead of abusing Replit's platform to host bots. There's nothing you can do about it.