Secrets wont work

Hi all,

I am trying to make my first discord bot.
I can get it to work, if I use my token directly.
But as soon as I use the secrets panel it wont work. (keyerror: “Token”)
It says the variable token hasnt been set, but the secret is “saved”
Please help

Repl link:

import discord
import os


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

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return


    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')


client.run(os.environ['TOKEN'])

The Key must be TOKEN (or, I prefer DISCORD_TOKEN) and the Value must be your bot token.

5 Likes

Thank you so much, I knew it had to be something silly like this!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.