I really need help and an answer would be pretty cool.
I'm trying to create my discord bot, and for that I installed discord.py, but it really doesn't want to work, I don't understand.
With each problem solved, a new one appears. I attach here my screens of my errors.
Help me please ! here is my script voici mon script
from discord.ext import commands
bot = commands.bot (command_prefix = "!")
@bot.event
async def on_ready():
print("on ready !")
bot.run("----")
and here is the error:
PS C:\Users\Mathis> & C:/Users/Mathis/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Mathis/Documents/bot python/main.py" Traceback (most recent call last): File "c:\Users\Mathis\Documents\bot python\main.py", line 4, in bot = commands.bot (command_prefix = "!") TypeError: 'module' object is not callable
CodePudding user response:
First you need to import the Discord module:
import discord
from discord.ext import commands
You also need to set your bot permissions under Discord Developers - Applications and declare your intentions in your code:
intent = discord.Intents.all()
So, your code would look something like this:
import discord
from discord.ext import commands
intent = discord.Intents.all()
bot = commands.Bot(command_prefix = "!", intents = intent)
@bot.event
async def on_ready():
print("Ready!")
bot.run('Token here')
Your bot will work fine like this.
CodePudding user response:
in bot = commands.bot (command_prefix = "!") TypeError: 'module' object is not callable
It's Bot with an uppercase B
.