Reputation:
@client.event
async def on_message(message):
content = message.content
author = message.author
print("{}: {}".format(author, content))
if message.content.startswith(".play"):
pass
elif message.content.startswith(".echo"):
content = message.content
#
"""
msg = message.content.split()
await message.delete()
output = ""
for word in msg[1:]:
output += word
output += " "
if "gay" in output:
await message.channel.send("Only the gay person is godlessarp")
else:
await message.channel.send(output)
#
"""
import random as r
words = ["..."]
word = r.choice(words)
user_input = ""
i = 0
guesses = 8
hint = ""
for i in range(7):
await message.channel.send("Guess the word!")
user_input = content
if guesses > 0:
if user_input == word:
await message.channel.send("YOU FOUND THE WORD!")
break
elif user_input != word:
try:
await message.channel.send("Incorrect!")
hint += word[i]
await message.channel.send("Here is the hint: " + hint)
i += 1
guesses -= 1
user_input = ""
print(i)
print(guesses)
except:
await message.channel.send("Game Over!")
elif guesses == 0:
await message.channel.send("Game Over!")
elif "<@!753572933594775663>" in content:
await message.channel.send("```If you need help please mail [email protected]```")
await message.channel.send("```Or you can Dm the high rank members!```")
elif message.content == ".play":
pass
When I write .echo it literally plays the game itself(it answers itself)I tried to reset the content at the start of the loop but it did not work.Also it sometimes stops??.Another problem is that i tried to put this game code on .play clause but when I type in the chat it doesn't respond, it doesn't give a error. So I commented .echo code and replaced it with game code. Now it works but still same loop...I couldn't find a way to prevent this please help!
Upvotes: 1
Views: 1323
Reputation: 4743
If you don't want bot to reply itself, you should add
@client.event
async def on_message(message):
if message.author.bot:
return
this, so if message author is a bot, it will ignore the message.
Upvotes: 4