前提・実現したいこと
DiscoedでBOTを作りたく、以下のコマンドをpythonで実行したときにエラーが発生し、探しても解決策が見つからないのでご教授願いたいです。
エラーメッセージ
Traceback (most recent call last): File "time.py", line 1, in <module> import discord File "C:\Program Files\Python37\lib\site-packages\discord\__init__.py", line 20, in <module> from .client import Client, AppInfo, ChannelPermissions File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 38, in <module> from .state import ConnectionState File "C:\Program Files\Python37\lib\site-packages\discord\state.py", line 36, in <module> from . import utils, compat File "C:\Program Files\Python37\lib\site-packages\discord\compat.py", line 32 create_task = asyncio.async ^ SyntaxError: invalid syntax
ソースコード
import discord import datetime client = discord.Client() pretime_dict = {} @client.event async def on_voice_state_update(before, after): print("ボイスチャンネルで変化がありました") if((before.voice.self_mute is not after.voice.self_mute) or (before.voice.self_deaf is not after.voice.self_deaf)): print("ボイスチャンネルでミュート設定の変更がありました") return if(before.voice_channel is None): pretime_dict[after.name] = datetime.datetime.now() elif(after.voice_channel is None): duration_time = pretime_dict[before.name] - datetime.datetime.now() duration_time_adjust = int(duration_time.total_seconds()) * -1 reply_channel_name = "general" reply_channel = [channel for channel in before.server.channels if channel.name == reply_channel_name][0] reply_text = after.name + " が "+ before.voice_channel.name + " から抜けました。 通話時間:" + str(duration_time_adjust) +"秒" await client.send_message(reply_channel ,reply_text) client.run("token")#ボットのトークン
試したこと
特になし
補足情報(FW/ツールのバージョンなど)
Windows10 Home x64
python3.7.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/24 06:20