0

I was trying to make a bot that if a message had certain keywords in it, it would say "why would you say",themessage,"?" but it recognises it's own messages so i tried to fix that but it still does. Here is my code:

import discord
from discord import user
client = discord.Client()
keywords = ["help", "william", "William", "Monkey", "monkey", "Monkaee", "monkaee", "monkae","Monkae"]
@client.event
async def on_message(message):
    for i in range(len(keywords)):
        if keywords[i] in message.content:
            message2 = "Why would you say", message.content, "?"
            if message.author.id == "750809710739062804":
                await message.channel.send("shut it botty", delete_after=5)
            else:
                await message.channel.send(message2, delete_after=5)

then my token but i'm not gonna put that in. the id is the bot's id so it shouldnt recognise its own message but it does

1 Answer 1

0

You are comparing an Integer to a String

    if message.author.id == "750809710739062804":

Try it without the quotes, like this:

    if message.author.id == 750809710739062804:

Also, if you're trying to concatenate strings you should use

     message2 = "Why would you say" + message.content + "?"

Instead of

     message2 = "Why would you say", message.content, "?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.