Kiddanube4
Kiddanube4

Reputation: 77

Discord Bot fails to execute simple commands | Python

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 !

Upvotes: 1

Views: 121

Answers (1)

LoahL
LoahL

Reputation: 2613

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)

Upvotes: 1

Related Questions