Skip to content

Commit d5be5f2

Browse files
authored
Add intents for prefixed commands (#333)
* Update prefixed-commands.mdx Signed-off-by: Marc13 <[email protected]> * Update prefixed-commands.mdx Signed-off-by: Marc13 <[email protected]> * Update prefixed-commands.mdx Signed-off-by: Marc13 <[email protected]> --------- Signed-off-by: Marc13 <[email protected]>
1 parent 5872d70 commit d5be5f2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/extensions/commands/prefixed-commands.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ async def on_message(message):
9191
import discord
9292
from discord.ext import commands
9393

94-
bot = commands.Bot(command_prefix="!")
94+
intents = discord.Intents.default()
95+
intents.message_content = True
96+
97+
bot = commands.Bot(command_prefix="!", intents=intents)
9598

9699
@bot.command()
97100
async def ping(ctx):
@@ -183,7 +186,10 @@ import discord
183186
from discord.ext import commands # Import the commands extension
184187
# discord.ext.commands are not the same as discord.commands!
185188

186-
bot = commands.Bot(command_prefix="!") # You can change the command prefix to whatever you want.
189+
intents = discord.Intents.default() #Defining intents
190+
intents.message_content = True # Adding the message_content intent so that the bot can read user messages
191+
192+
bot = commands.Bot(command_prefix="!", intents=intents) # You can change the command prefix to whatever you want.
187193

188194
@bot.command() # This is the decorator we use to create a prefixed command.
189195
async def ping(ctx): # This is the function we will use to create the command.

0 commit comments

Comments
 (0)