TransWikia.com

How can I send a message to a specific channel?

Stack Overflow Asked by Tuna Ariyurek on November 27, 2020

@client.event
async def on_message_delete(message):
    content = message.content
    author = message.author
    await message.channel.send("{}: {}".format(author, content))

I searched for it but I could not find any result. I tried to use client.get_channel("id") it gives typerror i tried to convert it to int but still it didnt work.
Can you help?

One Answer

TO send the retrieved data to specific guild and channel

specific_guild = client.get_guild( guild_id )#guild_id must be a integer
specific_channel = specific_guild.get_channel( channel_id )#channel_id must be a integer
await specific_channel.send("{}: {}".format(author, content))

To send the retrieved data to a specific channel in the same guild

specific_channel = message.guild.get_channel( channel_id )#channel_id must be a integer
await specific_channel.send("{}: {}".format(author, content))

Correct answer by Manoj A on November 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP