#๐Ÿ”’ how can i fix it?

70 messages ยท Page 1 of 1 (latest)

faint relicBOT
#

@safe sequoia

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.

glacial escarp
#

!d discord.ext.commands.Bot

faint relicBOT
#
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\.
glacial escarp
#

(Not a bot person, I just wanted to look at the signature.)

safe sequoia
#

then, what i should to do?

#

@glacial escarp

glacial escarp
#

I would suggest viewing other people's implementations of bots using this library.

safe sequoia
#

it works perfectly 1 y ago

glacial escarp
#

See what they do and model yours on that.

safe sequoia
glacial escarp
#

Oh, yes, discord.py and Discord itself changes fairly often. Old things stop working.

safe sequoia
#

bruh

glacial escarp
#

Well, we can begin by looking at the error message. It's asking for something you're not providing, an intents argument.

solemn bluff
#

intents=discord.Intents.default()

faint relicBOT
#
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.

safe sequoia
solemn bluff
#

To the discord.Bot()

#

Commands*

safe sequoia
#

client = commands.Bot(intents=discord.Intents.default())

#

like this? @solemn bluff

solemn bluff
#

Yes.

#

But also the other things

safe sequoia
#

client = commands.Bot(intents=discord.Intents.default())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix'

safe sequoia
sterile prairie
solemn bluff
#

You need to combine both. Your og code and intents

safe sequoia
safe sequoia
solemn bluff
#

command prefix

#

Naw im on mobile

sterile prairie
safe sequoia
#

client = commands.Bot(command_prefix="!", intents=intents) ?

safe sequoia
solemn bluff
#

Yes, where intents is discord.Intents.default()

safe sequoia
#

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?

brave flower
solemn bluff
#

Whatโ€™s all of ur code look like?

safe sequoia
solemn bluff
#

No here

safe sequoia
#

that's private

solemn bluff
#

I donโ€™t accept dms

sterile prairie
safe sequoia
#

@solemn bluff ?

sterile prairie
#

Are you making a client or a bot?

solemn bluff
#

Itโ€™s a bot

safe sequoia
solemn bluff
#

๐Ÿ’€

safe sequoia
solemn bluff
#

!rule 5

faint relicBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

safe sequoia
#

xd

sterile prairie
solemn bluff
#

o7 sorry

safe sequoia
safe sequoia
solemn bluff
#

Yeah idk how to use discord.py as a self bot. But is there any reason you canโ€™t just make a bot?

solemn bluff
#

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

safe sequoia
#

thanks

#

@solemn bluff@sterile prairie โค๏ธ

faint relicBOT
#
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.

#

๐Ÿ”’ how can i fix it?