Answer the question
In order to leave comments, you need to log in
How to get the nickname of the user who sent a message to discord?
there is an event in the code
bot = commands.Bot(command_prefix = "!")
hello_words = ["hello", "ku", "hello", "hello", "hi", "ky", "hi", "privet" , "hello", "drow"]
hello_words_ansver = ["Hello", "Ku", "Hey", "Hello", "Hi", "ky", "privet", "Drow", "Yes"]
@bot .event
async def on_message(message):
if message.content.lower() in hello_words:
await message.channel.send(hello_words_ansver[randint(0,len(hello_words_ansver)-1)])
await bot.process_commands(message)
meaning therein,that when the bot sees any greeting from the "hello_words" array above, it should respond to the chat with a random greeting from the "hello_words_ansver" array.
1) the sender's nickname is needed so that the bot can reply to him with the mention of "author.mention".
2) due to the fact that the greetings and responses of the bot are basically the same (the word "hello" is in both arrays), the bot begins to greet itself and an infinite loop is obtained.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question