Reputation: 11
I have been trying to make a discord bot but when I put this piece of code tougether the bot turned online but if I use the command there is no response from the bot.
I used the import command from their github
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.command()
async def test(ctx):
await ctx.send(content="Test")
bot.run('token')
Thanks.
Upvotes: 0
Views: 321
Reputation: 2720
With the latest Pycord versions (starting from 2.0.0b5 if I recall correctly), they use a Discord gateway version high enough that you have to enable the (privileged) message content intent both on your application's developer site (https://discord.com/developers/applications/YOUR_APPLICATION_ID/bot
, but you can also go to https://discord.com/developers/applications and then navigate to your bot page from there)
and in your code:
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
With this setup, your bot will receive message events with the content and can actually process your commands
Note that once your bot reaches 100 servers, this intent will require you to undergo a whitelisting process by Discord. Until then, you can freely enable the intent to test and build your bot
Upvotes: 4