Reputation: 41
Basically I need to combine these 3 on_message functions into 1 on_message function cause you can't have more than 1 on_message function in a discord.py bot. Here's my code:
@client.event
async def on_message(message):
if message.content.startswith('Jason derulo'):
await message.channel.send('Wiggle wiggle wiggle')
await client.process_commands(message)
@client.event
async def on_message(message):
if message.content.startswith('fast'):
await message.channel.send('She a runner she a track star')
await client.process_commands(message)
@client.event
async def on_message(message):
await client.process_commands(message)
if message.author.bot:
return
for badword in file:
if badword in message.content.lower():
await message.delete()
warnMessage = f"Hey {message.author.mention}! Don't say that!"
await message.channel.send(warnMessage, delete_after=5.0)
print(f"{message.author.name} tried saying: {badword}")
channel = client.get_channel(836232733126426666)
embed = discord.Embed(title=f"Someone tried to swear!", colour=0x2D2D2D)
embed.add_field(name="Person who tried to swear:", value=f"{message.author.name}", inline=False)
embed.add_field(name="What they tried to say:", value=f"{badword}", inline=False)
await channel.send(embed=embed)
return
await client.process_commands(message)
Upvotes: 0
Views: 59
Reputation: 2613
You just add all the if
together, but only use one await client.process_commands(message)
at the bottom:
@client.event
async def on_message(message):
if message.author.bot:
return
for badword in file:
if badword in message.content.lower():
await message.delete()
warnMessage = f"Hey {message.author.mention}! Don't say that!"
await message.channel.send(warnMessage, delete_after=5.0)
print(f"{message.author.name} tried saying: {badword}")
channel = client.get_channel(836232733126426666)
embed = discord.Embed(title=f"Someone tried to swear!", colour=0x2D2D2D)
embed.add_field(name="Person who tried to swear:", value=f"{message.author.name}", inline=False)
embed.add_field(name="What they tried to say:", value=f"{badword}", inline=False)
await channel.send(embed=embed)
return
await client.process_commands(message)
if message.content.startswith('Jason derulo'):
await message.channel.send('Wiggle wiggle wiggle')
if message.content.startswith('fast'):
await message.channel.send('She a runner she a track star')
await client.process_commands(message)
Upvotes: 1