Discord pyでユーザーのステータスによって、Botのステータスも変えたい…

前提

Discord py でDiscordBotを開発しています。

実現したいこと

自分が退席中(idle)状態の時にBotはオンラインになり、そうじゃない時は逆にBotが退席中表示になるBotを作りたいです。

発生している問題・エラーメッセージ

Ignoring exception in on_ready Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 23, in on_ready if user.status.idle: AttributeError: 'NoneType' object has no attribute 'status'

該当のソースコード

Python

@client.eventasync def on_ready(): user = get(client.get_all_members(), id="自分のID") if user.status.idle: await client.change_presence(status=discord.Status.online) else: await client.change_presence(status=discord.Status.idle)

試したこと

user = status.idle:にもしてみました

コメントを投稿

0 コメント