AGENT
AGENT

Reputation: 1

discord python bot isn't replying to commands

my discord bot isn't replying to commands does anyone know why? i also get an error that says discord.gateway: Shard ID None has connected to Gateway

token = 'mytoken'

import discord
client = discord.Client(intents=discord.Intents.default())


@client.event
async def on_ready():
print('we are logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.author == client:
    return

if message.content.startswith('$info'):
    message.channel.send(f'> i am a bot currently being developed by agent')


client.run(token)

Upvotes: 0

Views: 369

Answers (2)

Hunter Boyd
Hunter Boyd

Reputation: 127

You should use a bot instead of a client, and don't forget to await async functions. try this:

import discord
from discord.ext import commands

token = 'mytoken'

bot = commands.Bot(command_prefix='$')


@bot.event
async def on_ready():
    print('Ready!')

@bot.command()
async def info(ctx):
    await ctx.send('> i am a bot currently being developed by agent')


bot.run(token)

now try $info with the bot running.

Upvotes: 1

user19419589
user19419589

Reputation: 53

Try to use discord.ext.commands instead of discord.client

token = 'mytoken'

import discord
from discord.ext import commands
client = commands.Bot(intents=discord.Intents.default())


@client.event
async def on_ready():
print('we are logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.author == client:
    return

if message.content.startswith('$info'):
    message.channel.send(f'> i am a bot currently being developed by agent')

bot.process_commands(message)
client.run(token)

Upvotes: 0

Related Questions