'Checking What channel a message was sent in, discord.py

i am making a message logger for fun and i wanted to know if with it saying what was said and who said it if i could see what channel it was in and print it, here is the logger, everything works I just wanted to add specification of channel.

code:

async def on_message(message):
  msg = message.content
  hook.send(f'|{message.author.name}|{msg}')```


Solution 1:[1]

async def on_message(message):
  msg = message.content
  channel = message.channel
  hook.send(f'|{message.author.name}|{msg}')

It is all in the docs. If you want to also mention the channel in the a message, then just message.channel.mention

Solution 2:[2]

You can answer this question yourself by looking at the documentation for on_message(). The message parameter is a Message object. The documentation for Message lists the attributes which includes channel. If you need the channel's name, then look at the documentation for Channel. Learning how to navigate and read this documentation will be incredibly helpful as you continue to work on your bot.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mathias Sven
Solution 2 Code-Apprentice