Zoronic
Zoronic

Reputation: 5

Having problem with message sending command

I am trying to do a repeat command with this code:

import discord
from discord.ext import commands

bot = discord.Client()

client = commands.Bot(command_prefix='V!')


@client.command(name='repeat')
async def _repeat(ctx, arg):
    await ctx.send(arg)

bot.run('TOKEN')

but when sending a message with a command, the bot doesnt respond neither with the wanted message, nor an error that would imply something is not right. i am also very new to programming so it may be something dumb that i do not know. Any help is appreciated.

Upvotes: 0

Views: 138

Answers (1)

effprime
effprime

Reputation: 578

If you examine your code carefully, you'll see that you are assigning the command to the client object, but running the bot object. You need to do client.run("<TOKEN>") as another commenter suggested.

You also don't need bot = discord.Client() at all. discord.Client is a parent class with less abilities. I encourage you to rename client to bot though.

from discord.ext import commands

bot = commands.Bot(command_prefix='V!')

@bot.command(name='repeat')
async def _repeat(ctx, arg):
    await ctx.send(arg)

bot.run('TOKEN')

Notice now there's no import discord or discord.Client anywhere.

See: What are the differences between Bot and Client?

Upvotes: 1

Related Questions