Reputation: 13
i have a problem with my discord bot: when i type on discord $ping he doesn't response me pong and i don't know why, i just check the bot have the admin role so he can write, i'm using VsCode and he didn't give me nothing error.
Here is the code
import discord
from discord.ext import commands
import requests
import json
import random
client = discord.Client()
bot = commands.Bot(command_prefix='$')
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
client.run("XXXXXXXXXXXXXXXXXXXXXXX")
Upvotes: -1
Views: 126
Reputation: 2613
The problem is, that you are defining the command with bot.command
, but you only do client.run
. To fix this, either choose a client, or a bot, but not both, like this if you choose bot for example:
import discord
from discord.ext import commands
import json
import random
bot = commands.Bot(command_prefix='$')
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
bot.run(Token)
Also don't use requests, since it's blocking.
Upvotes: 2