#๐Ÿ”’ error with nextcord

52 messages ยท Page 1 of 1 (latest)

autumn crane
sweet spruceBOT
#

@autumn crane

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.

sweet spruceBOT
#
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.

velvet lake
#

what exactly do you not understand?

autumn crane
velvet lake
umbral bridge
#

It looks like there iz a problem with Nextcord about message content not being turned on. You will need to go to the discord dev portal and click on your bot then go to bots then go down a bit and toggle everything on. Because It might mess up how your bot's prefix commands work if itโ€™s off.

velvet lake
#

in your main file add

intents = nextcord.Intents.default()
intents.message_content = True
velvet lake
#

head into the discord developer portal and enable message intents for your bot

autumn crane
#

hmm alright

umbral bridge
velvet lake
umbral bridge
#

He has it

#

No one forgets it

#

๐Ÿ’€

velvet lake
#

a significant amount of people do

velvet lake
#

๐Ÿ‘

umbral bridge
#

Well he doesnโ€™t cuz it says itโ€™s not toggled on not that he didnโ€™t write it in the file

#

Stop acting smart gosh

velvet lake
#

I just pointed out a possible point where people commonly make errors

#

how is that acting smart?

autumn crane
velvet lake
autumn crane
#

nono i know this place

velvet lake
#

it'll be under privileged gateway intents

autumn crane
#

i cant find intents

velvet lake
#

you want the third one, underlined in red

autumn crane
#

its already enabled

#

weird

pearl current
velvet lake
#

and you passed in the intents in the required places?

autumn crane
#

from nextcord.ext import commands
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)
bot = commands.Bot(command_prefix="!")

@bot.command(name="hi")
async def SendMessage(ctx):
await ctx.send("Hello")

@bot.event
async def on_ready():
print(f"Logged in as: {bot.user.name}")

if name == "main":
bot.run("************")

sweet spruceBOT
#

Hey @autumn crane!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
velvet lake
#

from the nextcord docs, you need the latter from what I gather

 # Somewhere else:
 # client = nextcord.Client(intents=intents)
 # or
 # from nextcord.ext import commands
 # bot = commands.Bot(command_prefix='!', intents=intents)
velvet lake
#

that should fix it

autumn crane
#

hmm

#

it worked yes

#

thx so much

velvet lake
#

๐Ÿ‘

#

you can go ahead and !close if you don't have any further questions

autumn crane
#

maybe later i need

#

but not now

#

thx

#

!close

sweet spruceBOT
#
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.