1

I am trying to build a Discord bot; which tells you about the weather condition. But no matter what I did I was unable to execute even the simplest commands such as:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!")


@bot.command()
async def test(ctx, arg):
    await ctx.send(arg)

client = discord.Client()
client.run(token)

I just do not get it on Discord side I enter the command "!test hello" to the chat screen and nothing happens. Please help thanks !

1

1 Answer 1

1

The problem is, that you first define a bot using bot = commands.Bot(command_prefix="!") then add the command to the bot, but then create a new client using client = discord.Client() and then run the client. The problem here is that, you never run the bot, which has the command, so instead of

client = discord.Client()
client.run(token)

use

bot.run(token)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.