mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
Add message content intent to examples
This commit is contained in:
parent
2eec900e98
commit
5780ff5ef0
@ -1,4 +1,4 @@
|
|||||||
# This example requires the 'members' privileged intents
|
# This example requires the 'members' and 'message_content' privileged intents
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@ -11,6 +11,7 @@ There are a number of utility commands being showcased here.'''
|
|||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
|
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -123,8 +125,12 @@ class Music(commands.Cog):
|
|||||||
elif ctx.voice_client.is_playing():
|
elif ctx.voice_client.is_playing():
|
||||||
ctx.voice_client.stop()
|
ctx.voice_client.stop()
|
||||||
|
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"),
|
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"),
|
||||||
description='Relatively simple music bot example')
|
description='Relatively simple music bot example',
|
||||||
|
intents=intents)
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# This example requires the 'members' privileged intent to use the Member converter.
|
# This example requires the 'members' privileged intent to use the Member converter.
|
||||||
|
# This example also requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ from discord.ext import commands
|
|||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
bot = commands.Bot('!', intents=intents)
|
bot = commands.Bot('!', intents=intents)
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -28,8 +31,10 @@ class MyBot(commands.Bot):
|
|||||||
# use the new MyContext class
|
# use the new MyContext class
|
||||||
return await super().get_context(message, cls=cls)
|
return await super().get_context(message, cls=cls)
|
||||||
|
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
bot = MyBot(command_prefix='!')
|
bot = MyBot(command_prefix='!', intents=intents)
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def guess(ctx, number: int):
|
async def guess(ctx, number: int):
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
class MyClient(discord.Client):
|
class MyClient(discord.Client):
|
||||||
@ -17,5 +19,8 @@ class MyClient(discord.Client):
|
|||||||
msg = f'{message.author} has deleted the message: {message.content}'
|
msg = f'{message.author} has deleted the message: {message.content}'
|
||||||
await message.channel.send(msg)
|
await message.channel.send(msg)
|
||||||
|
|
||||||
client = MyClient()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
client = MyClient(intents=intents)
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@ -16,5 +18,8 @@ class MyClient(discord.Client):
|
|||||||
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
|
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
|
||||||
await before.channel.send(msg)
|
await before.channel.send(msg)
|
||||||
|
|
||||||
client = MyClient()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
client = MyClient(intents=intents)
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
@ -30,5 +32,8 @@ class MyClient(discord.Client):
|
|||||||
else:
|
else:
|
||||||
await message.channel.send(f'Oops. It is actually {answer}.')
|
await message.channel.send(f'Oops. It is actually {answer}.')
|
||||||
|
|
||||||
client = MyClient()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
client = MyClient(intents=intents)
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
class MyClient(discord.Client):
|
class MyClient(discord.Client):
|
||||||
@ -13,5 +15,8 @@ class MyClient(discord.Client):
|
|||||||
if message.content.startswith('!hello'):
|
if message.content.startswith('!hello'):
|
||||||
await message.reply('Hello!', mention_author=True)
|
await message.reply('Hello!', mention_author=True)
|
||||||
|
|
||||||
client = MyClient()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
client = MyClient(intents=intents)
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned, description="Nothing to see here!")
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
bot = commands.Bot(command_prefix=commands.when_mentioned, description="Nothing to see here!", intents=intents)
|
||||||
|
|
||||||
# the `hidden` keyword argument hides it from the help command.
|
# the `hidden` keyword argument hides it from the help command.
|
||||||
@bot.group(hidden=True)
|
@bot.group(hidden=True)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -5,7 +7,10 @@ import discord
|
|||||||
|
|
||||||
class Bot(commands.Bot):
|
class Bot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -5,7 +7,10 @@ import discord
|
|||||||
|
|
||||||
class CounterBot(commands.Bot):
|
class CounterBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -39,7 +41,10 @@ class DropdownView(discord.ui.View):
|
|||||||
|
|
||||||
class Bot(commands.Bot):
|
class Bot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
class EphemeralCounterBot(commands.Bot):
|
class EphemeralCounterBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -5,7 +7,10 @@ from urllib.parse import quote_plus
|
|||||||
|
|
||||||
class GoogleBot(commands.Bot):
|
class GoogleBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
@ -29,7 +31,10 @@ class PersistentView(discord.ui.View):
|
|||||||
|
|
||||||
class PersistentViewBot(commands.Bot):
|
class PersistentViewBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
self.persistent_views_added = False
|
self.persistent_views_added = False
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# This example requires the 'message_content' privileged intent to function.
|
||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
@ -120,7 +122,10 @@ class TicTacToe(discord.ui.View):
|
|||||||
|
|
||||||
class TicTacToeBot(commands.Bot):
|
class TicTacToeBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(command_prefix=commands.when_mentioned_or('$'))
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user