0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

discord.pyのsend_messageメソッドでエラーになった話

Last updated at Posted at 2019-04-19

久しぶりに暗号通貨用のスクリプトをいじって、Pypiの更新を適当にしてたらエラーが出たので書いてみます。
Discord.pyでメソッドの廃止があったようです(いつかは知らないけど

環境

  • windows10
  • python3.65

#原因

# before
await client.send_message(channel, 'Hello')

# after
await channel.send('Hello')

  • 他にもいろいろ変更ポイントがありそうでしたが、エラーが出なかったので見なかったことにしました。

修正後のソース


@client.event
async def on_message(message):
    if message.content.startswith('/aaaa'):
        reply = 'reply_message'
        #Before
        #await client.send_message(message.channel, reply)
        #after
        await message.channel.send(reply)
  • チャットBotでメッセージを貰って、リプライするところの実装です。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?