Aadim Chaulagain
Aadim Chaulagain

Reputation: 33

How could I send the message to the specific channel using discord.py?

So, I am making a discord bot where the bot creates a new private channel and deletes it once the commands completed(or after 15 minutes timeout).

But the thing I cannot do correctly is send message to that newly created channel. I cannot just do ctx.send and I have tried this stuff already and didn't work for me.

I tried this but it didn't work:

channel = client.get_channel(12324234183172)
await channel.send('hello')

Upvotes: 1

Views: 162

Answers (1)

DriftAsimov
DriftAsimov

Reputation: 413

guild.create_text_channel returns the text channel object, you can use it this way:

channel = await guild.create_text_channel("foo")
await channel.send("hi")

You might like to read the docs here about creating channels: https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.create_text_channel

Upvotes: 2

Related Questions