Reputation: 3
basically i have no idea why this code is not working, ive tried using on_message and that works so long as i dont include and if statement to filter for the messages with the prefix at the start. so i scrapped that, this code worked a few months ago with a different bot i made and ive ended up scrapping all the other stuff i was doing and bringing it down to the bare basics because i cant figure out why the bot doesnt recognise messages starting with the prefix.
import discord
import os
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
TOKEN = "Token_here"
@bot.command(name='tst')
async def test(ctx):
await ctx.send('testt')
@bot.event
async def on_ready():
print ('Successful login as {0.user}'.format(bot))
bot.run(TOKEN)
ive tried print('Test') debugging aswell see below
@bot.command(name='tst')
async def test(ctx):
print('Test")
then in discord typing the !test command still does nothing and the terminal also remains empty other than the on_ready result of
Successful login as botname#0001
i have no idea whats going on honestly
Upvotes: 0
Views: 915
Reputation: 49
Try these changes:
bot= commands.Bot(command_prefix='!!', intents=discord.Intents.all())
@bot.command()
async def test():
await ctx.channel.send("Test successful")
Upvotes: 0
Reputation: 73
There are a couple of things that could be causing your problems. I fixed the issue by enabling intents for the bot. This also must be done on the developer portal. https://discord.com/developers/applications
intents = discord.Intents().all()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
you also don't need the name parameter in the command decorator. It can just be written as :
@bot.command()
async def test(ctx):
await ctx.send('testt')
Upvotes: 0