#๐ how can i fix it?
70 messages ยท Page 1 of 1 (latest)
@safe sequoia
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.
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, ...)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2\.0\.
(Not a bot person, I just wanted to look at the signature.)
I would suggest viewing other people's implementations of bots using this library.
it works perfectly 1 y ago
See what they do and model yours on that.
i want this one, u know how can i fix it
Oh, yes, discord.py and Discord itself changes fairly often. Old things stop working.
bruh
Well, we can begin by looking at the error message. It's asking for something you're not providing, an intents argument.
intents=discord.Intents.default()
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.
add it where?
client = commands.Bot(intents=discord.Intents.default())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix'
what
Read this โ๏ธ
You need to combine both. Your og code and intents
can u edite this?
can u send
What?
client = commands.Bot(command_prefix="!", intents=intents) ?
edite code to correct one and send it if you can
Yes, where intents is discord.Intents.default()
Naw
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
@solemn bluff
can i send you code in dm?
thats not how this discord server works
people dont fix your code for you, you are supposed to do it yourself
Whatโs all of ur code look like?
lemme send in your dm
No here
that's private
I donโt accept dms
I think you need to learn the basics properly on how to make a Discord bot. This is a fantastic resource: https://fallendeity.github.io/discord.py-masterclass/
A hands-on guide to Discord.py
@solemn bluff ?
Are you making a client or a bot?
Itโs a bot
somthing like selfbot
๐
yeah, then hw can i fix
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
xd
lol ๐
o7 sorry
@solemn bluff i said lemme send in dm cuz of this
c'mon
Yeah idk how to use discord.py as a self bot. But is there any reason you canโt just make a bot?
:D
you dont know
really?
Yea ik how to make actually bots with the applications, but not a self bot. And even if I did know I canโt just put it here ๐ also itโs against tos, the account will be banned
okey
thanks
@solemn bluff@sterile prairie โค๏ธ
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.
๐ how can i fix it?