Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.73k stars 3.74k forks source link

await client.send_message(discord.Object(id='123456'), 'hello') does not work #1640

Closed wrgsRay closed 5 years ago

wrgsRay commented 5 years ago

I want to send a message to a specific channel when the bot goes online by adding an example I found here: https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-send-a-message-to-a-specific-channel

    @bot.event
    async def on_ready():
        print('We have logged in as {0.user}'.format(bot))
        await bot.change_presence(status=discord.Status.idle, activity=activity)
        await bot.send_message(discord.Object(id='123456'), 'hello')

The error I got was:

await bot.send_message(discord.Object(id='123456'), 'hello')
AttributeError: 'Bot' object has no attribute 'send_message'

I am using the latest version of discord py 1.0

Harmon758 commented 5 years ago

This example is for the async branch. For the rewrite branch, see https://discordpy.readthedocs.io/en/rewrite/faq.html#how-do-i-send-a-message-to-a-specific-channel.

For future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.

wrgsRay commented 5 years ago

Harmon758,

Thanks. Done and done.