How can I make a Discord Bot work?

Whenever I try to code my Discord bot (and I’ve tried many tutorials) I get this error:

image

This is the only code I have:


import os, re, discord
from discord.ext import commands

DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")

bot = commands.Bot(command_prefix="!")

@bot.event
async def on_ready():
    print(f"{bot.user} has connected to Discord!")

bot.run(DISCORD_TOKEN)

The tutorial you used was outdated.

Use bot = commands.Bot(command_prefix="!", intents= discord.Intents.default())

2 Likes

(1) THAT WAS SO FAST.
(2) Thank you, that fixed it!

Me and my friend are trying to make bots and we got frustrated over that because every tutorial online gave us the same error. Every tutorial must be outdated.

1 Like

Well the change was very recent, and most people don’t make tutorials that fast.

1 Like

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