pythonmacosdiscord.py

Intents - Discord - Python - MacOs


So here is my code :

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ',')

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

@client.event
async def on_ready():
    print('Discord.py is working fine')

client.run("<Token>")

I have found on internet some simple code for discord bot on python, but like a lot of other people I always have the same error ... INTENTS !!!!!

Here is my error :

Traceback (most recent call last):
  File "/Users/<Users>/Desktop/Discord/BUt.py", line 4, in <module>
    client = commands.Bot(command_prefix = ',')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'

PLEASE !! Help me !! I don't know how to do. I'm at the bottom of the hole (this is a french expression to say that you can't take it anymore). For the information I'm french (you have understood) and I'm on mac.


Solution

  • The mistake you made is simple to correct. You defined the same thing twice

    client = commands.Bot(command_prefix = ',',intents=discord.Intents.all())

    and delete these:

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

    So your code looks like this:

    import discord
    from discord.ext import commands
    
    client = commands.Bot(command_prefix = ',',intents = discord.Intents.all())
    
    @client.event
    async def on_ready():
        print('Discord.py is working fine')
    
    client.run("<Token>")