-1

Commands are imported from discord.ext. The PREF is '!'.

client = commands.Bot(command_prefix=PREF)

This event below is working.

    @client.event
async def on_message(message):
    wordd = 'say home'
    if wordd in message.content:
        await message.channel.send("home")

But this command below is not working...

@client.command()
async def welcome(ctx):
    tablica = ["czesc", "siema", "witaj"]
    await ctx.channel.send(random.choice(tablica))

Anyone help?

'

import discord
from discord.ext import commands



PREF = '!'
client = commands.Bot(command_prefix=PREF)
client.remove_command("help")


@client.event
async def on_message(message):
    wordd = 'say home'
    if wordd in message.content:
        await message.channel.send("home")



@client.command()
async def welcome(ctx):
    tablica = ["czesc", "siema", "witaj"]
    await ctx.channel.send(random.choice(tablica))





client.run(<token>)
ad_progg
  • 11
  • 2
  • 1
    Does this answer your question? [Why does on\_message stop commands from working?](https://stackoverflow.com/questions/49331096/why-does-on-message-stop-commands-from-working) – TheFungusAmongUs Jul 18 '22 at 22:30

1 Answers1

0

You have to use await client.process_commands(message) at the end of the on_message command

import discord
from discord.ext import commands



PREF = '!'
client = commands.Bot(command_prefix=PREF)
client.remove_command("help")


@client.event
async def on_message(message):
    wordd = 'say home'
    if wordd in message.content:
        await message.channel.send("home")
    await client.process_commands(message)



@client.command()
async def welcome(ctx):
    tablica = ["czesc", "siema", "witaj"]
    await ctx.channel.send(random.choice(tablica))





client.run(<token>)

DOCS

Shweta K
  • 249
  • 2
  • 10