Discord bot token error

So my code:

import discord
from discord.ext import commands
from discord import app_commands

bot = commands.Bot(command_prefix="-", intents=discord.Intents.all())


@bot.event
async def on_ready():
  print("HybridSMP now online!")


@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
  if reason == None:
    reason = "**No reason provided**"
  await ctx.guild.kick(member)
  await ctx.send(f"User {member.mention} has been kicked for {reason}.")


bot.run("TOKEN IS HERE IN MY CODE. NOT SHARING FOR PRIVACY REASONS")

I am getting the error of
File "main.py", line 22, in <module> bot.run("TOKEN IS HERE IN MY CODE. NOT SHARING FOR PRIVACY REASONS") File "/home/runner/HybridSMP-Bot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run asyncio.run(runner())

Any ideas on why?

Hello @ShaunMostert !

First of all:

Use the Secrets function in replit, this allows you to hide your token from public view and it’s a good security pratice:
https://docs.replit.com/programming-ide/workspace-features/secrets

Second:
We need the full error description, the error you are showing is just indicating where your script is existing. Copy the full error message and give us here.

3 Likes