Skip to content

Commit 0a1b6b0

Browse files
Adds message_content intent to examples. (#1053)
* Add message_content intent. * Adds message_content intent to examples. * Add intents to commands.Bot options. * Add intents to background task example. * Add intents to background task * Add intents to converters * Remove message_content intent from background_task * Remove message_content intent from backgorund_task_asyncio * Add note * Update examples/converters.py Co-authored-by: plun1331 <[email protected]> Co-authored-by: plun1331 <[email protected]>
1 parent 9f065aa commit 0a1b6b0

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

examples/background_task.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ async def my_background_task(self):
2626
async def before_my_task(self):
2727
await self.wait_until_ready() # Wait until the bot logs in
2828

29-
3029
client = MyClient()
3130
client.run("token")

examples/background_task_asyncio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ async def my_background_task(self):
2323
await channel.send(counter)
2424
await asyncio.sleep(60) # This asyncio task runs every 60 seconds
2525

26-
2726
client = MyClient()
2827
client.run("token")

examples/basic_bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This example requires the 'members' privileged intents
1+
# This example requires the 'members' and 'message_content' privileged intents
22

33
import random
44

@@ -12,6 +12,7 @@
1212

1313
intents = discord.Intents.default()
1414
intents.members = True
15+
intents.message_content = True
1516

1617
bot = commands.Bot(command_prefix="?", description=description, intents=intents)
1718

examples/basic_voice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This example requires the 'message_content' privileged intent.
2+
13
import asyncio
24

35
import youtube_dl
@@ -121,10 +123,13 @@ async def ensure_voice(self, ctx):
121123
elif ctx.voice_client.is_playing():
122124
ctx.voice_client.stop()
123125

126+
intents = discord.Intents.default()
127+
intents.message_content = True
124128

125129
bot = commands.Bot(
126130
command_prefix=commands.when_mentioned_or("!"),
127131
description="Relatively simple music bot example",
132+
intents=intents,
128133
)
129134

130135

examples/converters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This example requires the 'members' privileged intent to use the Member converter.
1+
# This example requires the 'members' privileged intent to use the Member converter, and the 'message_content' privileged intent for prefixed commands.
22

33
import typing
44

@@ -7,6 +7,7 @@
77

88
intents = discord.Intents.default()
99
intents.members = True
10+
intents.message_content = True
1011

1112
bot = commands.Bot("!", intents=intents)
1213

0 commit comments

Comments
 (0)