Discord Bot - Adding multiple commands

Hello, I am trying to create a discord bot using Beau Carnes’ discord.py bot tutorial
The thing is when I run this code:

import discord
import os 
import random
from keep_alive import keep_alive

client = discord.Client()

@client.event
async def on_ready():
  print('We have logged in as {0.user}'.format(client))


@client.event
async def on_message(message):
    if message.content.startswith('ub help'):
        embedVar = discord.Embed(title="UltremeBot Commands", description="See all of UltremeBot's commands (add ub before any command)", color=0x2C2F33)
        embedVar.add_field(name="joke", value="Laugh out Loud!", inline=False)
        embedVar.add_field(name="Field2", value="hi2", inline=False)
        await message.channel.send(embed=embedVar) 


keep_alive()
client.run(os.getenv('TOKEN')) 

it seems to be working just fine. But when I add a list and another command, it doesn’t work.

import discord
import os 
import random
from keep_alive import keep_alive
joke = ['joke1', 'joke2', 'joke3']

client = discord.Client()

@client.event
async def on_ready():
  print('We have logged in as {0.user}'.format(client))


@client.event
async def on_message(message):
    if message.content.startswith('ub help'):
        embedVar = discord.Embed(title="UltremeBot Commands", description="See all of UltremeBot's commands (add ub before any command)", color=0x2C2F33)
        embedVar.add_field(name="joke", value="Laugh out Loud!", inline=False)
        embedVar.add_field(name="Field2", value="hi2", inline=False)
        await message.channel.send(embed=embedVar) 

@client.event
async def on_message(message):  
    if message.content.startswith('ub joke'):
        embedVar = discord.Embed(title='Joke', description=(random.choice(joke)))


keep_alive()
client.run(os.getenv('TOKEN'))  

Can someone pleaase help me with this. Thank You.

may it be that you need to add the other options of what to do inside the same function?

I had barely started this one, I will have to get back to it, but what I would have done was to add an elif and add other options here:

add inside that elif message.content.startswith('ub joke'): and the rest of the logic

I don’t think you can have multiple functions with the same name and expect all of them to work

1 Like

Ah yes. I tottaly forgot to add ‘await message.channel.send(embed=embedVar)’
Thanks