実現したいこと
表題の通り、VC へ bot を接続したい
前提
discord.py-interactions[voice] を利用しています。
ボイスチャンネルに接続しようと、bot を context から connect() したところ、時間内に接続できないように見える
エラーが発生するのは利用しているVPS (Ubuntu 20.04) 上で実行したときで、ローカルマシン (Windows 11 23H2) で実行したときはしっかりと完了することを確認しております。
発生している問題・エラーメッセージ
エラーメッセージは発生していませんが、コンソールで実行中にCtrl+C
すると以下のエラーメッセージを出力しました
/usr/lib/python3.12/asyncio/events.py:88: RuntimeWarning: The executor did not finishing joining its threads within 300 seconds. self._context.run(self._callback, *self._args) ^CException ignored in: <module 'threading' from '/usr/lib/python3.12/threading.py'> Traceback (most recent call last): File "/usr/lib/python3.12/threading.py", line 1592, in _shutdown atexit_call() File "/usr/lib/python3.12/concurrent/futures/thread.py", line 31, in _python_exit t.join() File "/usr/lib/python3.12/threading.py", line 1147, in join self._wait_for_tstate_lock() File "/usr/lib/python3.12/threading.py", line 1167, in _wait_for_tstate_lock if lock.acquire(block, timeout): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyboardInterrupt: Task exception was never retrieved
該当のソースコード
py
1from interactions import ( 2 Client, 3 Intents, 4 Task, 5 listen, 6 slash_command, 7 slash_option, 8 SlashContext, 9 OptionType, 10 ChannelType, 11 models, 12 SlashCommandChoice, 13 Webhook, 14 IntervalTrigger, 15 TimeTrigger, 16 Activity, 17 VoiceState, 18 ActiveVoiceState, 19 BaseChannel 20) 21 22bot = Client(intents=Intents.DEFAULT|Intents.GUILD_VOICE_STATES, delete_unused_application_cmds=True) 23 24~~~ 25 26@slash_option( 27 name="command", 28 description="対象の操作", 29 required=True, 30 opt_type=OptionType.STRING, 31 choices=[ 32 SlashCommandChoice(name="TTSを接続", value="tts_join"), 33 SlashCommandChoice(name="TTSを切断", value="tts_disconnect"), 34 ~~~ 35 ] 36) 37@slash_option( 38 name="channel", 39 description="対象のチャンネル", 40 required=True, 41 opt_type=OptionType.CHANNEL, 42 channel_types=[ChannelType.GUILD_VOICE], 43) 44async def voice(ctx: SlashContext, command: str, channel: int): 45 log(f"requested command: voice, Options: {command}, {channel.name}") 46 await ctx.defer() 47 48~~~ 49 50 elif command == "tts_join": 51 if not ctx.voice_state: 52 log(f"connecting to {channel}") 53 connected = await channel.connect(deafened=True) 54 await ctx.send(f"{channel.name} に接続しました", delete_after=15) 55 log(f"success! connected to {connected}") 56 else: 57 await ctx.send(f"既に {ctx.voice_state.channel.name} に接続済みです") 58 log(f"failed! already connected to {ctx.voice_state.channel}") 59 60 elif command == "tts_disconnect": 61 if ctx.voice_state: 62 await ctx.send("切断しました", delete_after=15) 63 await ctx.voice_state.channel.disconnect() 64 log(f"success! disconnected from {ctx.voice_state.channel.name}") 65 else: 66 await ctx.send(f"切断に失敗しました\n```log\ncontext: {ctx}\ncontext voice_state: {ctx.voice_state}\nauthor voice_state: {ctx.author.voice}\ncurrent active_voice_state: {current_vc}\n```") 67 log(f"failed! couldnt disconnect") 68 69~~~ 70 71bot.start(TOKEN)
試したこと
該当のコードである、
py
1 elif command == "tts_join": 2 if not ctx.voice_state:
のコードブロックに含まれる行の順番を入れ替えるなどは試してみましたが、改善は見られませんでした。
また、その時に connected = await channel.connect(deafened=True)
の行以降のコードブロック内のコードが実行されていないことから、この行が何かしらの処理に失敗しているのではないかと思っています。
補足情報(FW/ツールのバージョンなど)
Ubuntu 20.04
# python3.12 -version Python 3.12.4 # pip list Package Version ------------------------- ----------- aiohttp 3.9.5 aiosignal 1.3.1 async-timeout 4.0.3 attrs 23.2.0 cachetools 5.3.3 certifi 2024.7.4 cffi 1.16.0 charset-normalizer 3.3.2 croniter 2.0.5 discord-py-interactions 5.13.1 discord-typings 0.9.0 emoji 2.12.1 frozenlist 1.4.1 google-api-core 2.19.1 google-auth 2.31.0 google-cloud-texttospeech 2.16.3 googleapis-common-protos 1.63.2 grpcio 1.64.1 grpcio-status 1.64.1 idna 3.7 multidict 6.0.5 packaging 24.1 pip 24.1.1 pip-review 1.3.0 proto-plus 1.24.0 protobuf 5.27.2 psutil 6.0.0 pyasn1 0.6.0 pyasn1_modules 0.4.0 pycparser 2.22 PyNaCl 1.5.0 python-dateutil 2.9.0.post0 pytz 2024.1 requests 2.32.3 rsa 4.9 schedule 1.2.2 setuptools 70.2.0 six 1.16.0 tomli 2.0.1 typing_extensions 4.12.2 urllib3 2.2.2 yarl 1.9.4
Windows 11 Pro 23H2
> python --version Python 3.12.3 > pip list Package Version ------------------------- ----------- aiohttp 3.9.5 aiosignal 1.3.1 async-timeout 4.0.3 attrs 23.2.0 cachetools 5.3.3 certifi 2024.7.4 cffi 1.16.0 charset-normalizer 3.3.2 croniter 2.0.5 discord-py-interactions 5.13.1 discord-typings 0.9.0 emoji 2.12.1 frozenlist 1.4.1 google-api-core 2.19.1 google-auth 2.31.0 google-cloud-texttospeech 2.16.3 googleapis-common-protos 1.63.2 grpcio 1.64.1 grpcio-status 1.64.1 idna 3.7 multidict 6.0.5 packaging 24.1 pip 24.1.1 pip-review 1.3.0 proto-plus 1.24.0 protobuf 5.27.2 psutil 6.0.0 pyasn1 0.6.0 pyasn1_modules 0.4.0 pycparser 2.22 PyNaCl 1.5.0 python-dateutil 2.9.0.post0 pytz 2024.1 requests 2.32.3 rsa 4.9 schedule 1.2.2 six 1.16.0 tomli 2.0.1 typing_extensions 4.12.2 urllib3 2.2.2 yarl 1.9.4

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。