Discord.py: Send message to specific channel

Created on 6 May 2018  路  10Comments  路  Source: Rapptz/discord.py

Hello There again!

How do i send a message in a specific channel? For example on join of a member i wan't to send a message in the welcome channel. I tried copying the Channel ID and did this:
await client.send_message(442646501433540608, "Welcome to The Hole of Freedom @" + str(member))

But i don't get any message. Or could it be that i test this with a discord bot?

Most helpful comment

http://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-send-a-message-to-a-specific-channel

All 10 comments

http://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-send-a-message-to-a-specific-channel

Thank You! Somehow couldn't find it myself...

Couple of things here:

For future questions like these, join the discord.py support server: https://discord.gg/r3sSKJJ

Hi!
What needs to be imported for this to work?

You only need to import discord to use this.

await channel.send('hello') ^ SyntaxError: 'await' outside function i get this error when i try to run it, anyone has a fix for this?

await channel.send('hello') ^ SyntaxError: 'await' outside function i get this error when i try to run it, anyone has a fix for this?

What have you set channel equal to?

Don鈥檛 necrobump old issues, and as your error says, you can only use await within an asynchronous function.

Can i do this by getting the user args with the channel tagged?

Don鈥檛 necrobump old issues, and as your error says, you can only use await within an asynchronous function.

Please do not necrobump old issues, especially when the last comment in the issue was telling somebody not to do this. If you'd like help with the library, please join the Official Support Server as the README suggests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Spyder-exe picture Spyder-exe  路  3Comments

Rimmy50 picture Rimmy50  路  3Comments

adhoc92 picture adhoc92  路  3Comments

j0hnmeow picture j0hnmeow  路  3Comments

JackL0 picture JackL0  路  3Comments