#๐Ÿ”’ error intent

31 messages ยท Page 1 of 1 (latest)

quick hornet
#

every time i run this i get a error and im not sure how to fix it, i was building this bot according to a site. ```py
Traceback (most recent call last):
File "C:\Users\idkla\AppData\Local\Programs\Python\Python312\Python discord bot\Python bot p3 full h.py", line 64, in <module>
bot = commands.Bot(command_prefix='!')
TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'

wicked salmonBOT
#

@quick hornet

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

quick hornet
#

this is my code:

wicked salmonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

quick hornet
#

huh

#

i enabled intents

#

wait hold on

robust kite
#

you havn't passed it into your bot

quick hornet
#

but intents werent imported

robust kite
#

isn't that the problem?

quick hornet
robust kite
quick hornet
robust kite
quick hornet
quick hornet
robust kite
#

Interesting... It really doesn't

quick hornet
robust kite
quick hornet
#

!paste

wicked salmonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

quick hornet
#

should i just close this then?

quick hornet
robust kite
quick hornet
#

!close

wicked salmonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.