Reputation: 119
I am attempting to make a logging bot however I am having issues with message.channel.id
What is sent upon event being triggered; Message ID - Message ID | User - User ID | Their Message | My private log channel - Server where they sent message
Intended application of the code; Message ID - Message ID | User - User ID | Their Message | Server where they sent the message - Server where they sent message
@bot.event
async def on_message(message):
user = message.author
user_id = message.author.id
message_id = message.id
content = message.content
channel = message.channel.id
guild = message.guild
if user.bot:
return
channel = bot.get_channel(my private log channel)
await channel.send(f"Message ID - {message_id} **|** {user} - {user_id} **|** {content} **|** #{channel} - {guild}")
await bot.process_commands(message)
Upvotes: 2
Views: 2865
Reputation: 942
You used twice the same variable channel
just rename ones of them
Here is an example of a change of the 2 lines:
@bot.event
async def on_message(message):
user = message.author
user_id = message.author.id
message_id = message.id
content = message.content
message_channel = message.channel.id
guild = message.guild
if user.bot:
return
channel = bot.get_channel(my private log channel)
await channel.send(f"Message ID - {message_id} **|** {user} - {user_id} **|** {content} **|** #{message_channel} - {guild}")
await bot.process_commands(message)
Upvotes: 2