D
D
DmitrNy ---2019-12-09 19:45:27
Python
DmitrNy ---, 2019-12-09 19:45:27

[DISCORD.PY] How can I find out the id and name of the channel and server where the message was sent, given async def on_message(message)?

Hello, there is a bot that receives all messages from the servers where it is. I need to sort these messages. And for this you need to know where and by whom it was sent. Could you tell me how to find out at the machine level exactly where the message was sent (ID and name of the server and channel)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alice Cherry, 2019-12-29
@ytochka_alisa

Everything is described in the documentation - https://discordpy.readthedocs.io/en/latest/api.html

async def on_message(message):
    print(message.channel.name)  # имя канала
    print(message.channel.id)  # ID канала

A
Alex_Lovser, 2020-12-09
@Alex_Lovser

@bot.command()
async def voice_id(ctx):
channel = ctx.message.author.voice.channel
print(channel.id)
this is to find out the voice id in principle, go to the voice and write this command, well, it’s in your console id writes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question