0

so I'm working on making my own bot for my server and after a while I finally found a string for autorole & role assignment that worked. I then kept on adding another string for the bot simply replying "Hello". As soon as I add that the role commands won't work anymore. Once I take it out it works again. On the other hand I have a 8ball and a dice roll command that works with and without the Hello Command I have no idea what is the problem...

@client.event
async def on_member_join(member):
    channel = discord.utils.get(member.guild.channels, name='entrance')
    await channel.send(f'Welcome {member.mention} to Dreamy Castle! \n Please make sure to read the rules!')
    role = discord.utils.get(member.guild.roles, name="Peasants")
    await member.add_roles(role)

@client.event
async def on_message(message):
    if message.content.startswith('+acceptrules'):
        member = message.author
        role1 = discord.utils.get(member.guild.roles, name='The People')
        await member.add_roles(role1)

@client.event #this is the hello command
async def on_message(message):
    message.content.lower()
    if message.content.startswith('Hello Conny'):
        await message.channel.send('Hello!')
Dreamy
  • 3
  • 1
  • 2
  • It's already answered here: https://stackoverflow.com/questions/49331096/why-does-on-message-stop-commands-from-working – Exclbr Aug 13 '20 at 17:05

1 Answers1

0

Use if and elif not 2 different functions for same event.

Also you might need commands.Bot for a fully functional commanded bot.

@client.event
async def on_message(message):
    if message.content.startswith('+acceptrules'):
        member = message.author
        role1 = discord.utils.get(member.guild.roles, name='The People')
        await member.add_roles(role1)
    elif message.content.lower().startswith("hello conny"):
        await message.channel.send("Hello!")
    await client.process_commands(message)

Just for fun
  • 4,102
  • 1
  • 5
  • 11