Making a bot handle logs
Question:
I would like my bot to be able to handle logs. A log message would be like this:
Username: [User]
Stocked items: [Value]
Location: [Value]
Proof: [Image]
My goal is to make that when someone reacts to this message, in a certain channel, it will take the user [user]
as a variable and then do an action with it. The current code I have for it is this:
@client.event
async def on_message(message):
await client.wait_for()
I do not know how to make the bot waits for the reaction, neither how to copy the [user]
Answers:
Here is a slightly modified snippet from the Docs that should fit your needs.
Documentation on wait_for
can be found Here.
@client.event
async def on_message(message):
await client.wait_for()
def check(reaction, user):
return user == message.author and str(reaction.emoji) == ' '
try:
reaction, user = await Me.client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await message.channel.send(' ')
else:
await message.channel.send(' ')
with open("users.txt", "a") as f:
f.write(f"""
===========================
Username: {message.author.name}#{message.author.discriminator}
ID: {message.author.id}
Stocked items: [Value]
Location: [Value]
Proof: [Image]
""")
I would like my bot to be able to handle logs. A log message would be like this:
Username: [User]
Stocked items: [Value]
Location: [Value]
Proof: [Image]
My goal is to make that when someone reacts to this message, in a certain channel, it will take the user [user]
as a variable and then do an action with it. The current code I have for it is this:
@client.event
async def on_message(message):
await client.wait_for()
I do not know how to make the bot waits for the reaction, neither how to copy the [user]
Here is a slightly modified snippet from the Docs that should fit your needs.
Documentation on wait_for
can be found Here.
@client.event
async def on_message(message):
await client.wait_for()
def check(reaction, user):
return user == message.author and str(reaction.emoji) == ' '
try:
reaction, user = await Me.client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await message.channel.send(' ')
else:
await message.channel.send(' ')
with open("users.txt", "a") as f:
f.write(f"""
===========================
Username: {message.author.name}#{message.author.discriminator}
ID: {message.author.id}
Stocked items: [Value]
Location: [Value]
Proof: [Image]
""")