前提・実現したいこと
Discordでランダムに発言する話題提供Botを作っているのですが
実行させた所動作は正常にするのですが、終了時にエラーが発生してしまいます。
プログラムの初心者なので調べ方が下手なのかもしれませんが、軽く調べてみた所
loopに関することのようなのですが、特別loopに関するものを記述した覚えがなく
またネットの解決法も私のとは事例が違っていて参考にできなかったので
質問させていただきました。
解決法など教えていただけるとと幸いです。
素人質問ですいません。
発生している問題・エラーメッセージ
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000000037BADC0> Traceback (most recent call last): File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed
該当のソースコード
python
1import discord 2import random 3import time 4import asyncio 5from random import randint 6 7TOKEN = 'O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0O0' 8 9client = discord.Client() 10 11@client.event #初回起動時の処理 12async def on_ready(): 13 print('起動しました') 14 15@client.event #Botのコマンド送信周りの処理 16async def on_message(message): 17 if "!開始" in message.content: 18 modeselect = randint(1,5) 19 members = [i.name for i in message.author.voice.channel.members] 20 await message.channel.send() 21 if modeselect == 1: 22 time.sleep(3) 23 await message.channel.send("お題!") 24 await message.channel.send("対象者↓") 25 time.sleep(2) 26 await message.channel.send((random.choice(members))) 27 Ikari = ["適当な内容","適当な内容","適当な内容","適当な内容","適当な内容"] 28 await message.channel.send(random.choice(Ikari)) 29 time.sleep(random.randint(1,5)) 30 await message.channel.send("終了") 31 32 if modeselect == 2: 33 time.sleep(3) 34 await message.channel.send("お題!") 35 await message.channel.send("対象者↓") 36 time.sleep(2) 37 await message.channel.send((random.choice(members))) 38 Naru = ["適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容"] 39 await message.channel.send(random.choice(Naru)) 40 time.sleep(random.randint(1,5)) 41 await message.channel.send("終了") 42 43 if modeselect == 3: 44 time.sleep(3) 45 await message.channel.send("お題!") 46 await message.channel.send("対象者↓") 47 time.sleep(2) 48 await message.channel.send((random.choice(members))) 49 Hanasu = ["適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容"] 50 await message.channel.send(random.choice(Hanasu)) 51 time.sleep(random.randint(1,5)) 52 await message.channel.send("終了") 53 54 if modeselect == 4: 55 time.sleep(3) 56 await message.channel.send("お題!") 57 await message.channel.send("対象者↓") 58 time.sleep(2) 59 await message.channel.send((random.choice(members))) 60 Bakuro = ["適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容露"] 61 await message.channel.send(random.choice(Bakuro)) 62 time.sleep(random.randint(1,5)) 63 await message.channel.send("終了") 64 65 if modeselect == 5: 66 time.sleep(3) 67 await message.channel.send("お題!") 68 await message.channel.send("対象者↓") 69 time.sleep(2) 70 await message.channel.send((random.choice(members))) 71 Mutya = ["適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容","適当な内容"] 72 await message.channel.send(random.choice(Mutya)) 73 time.sleep(random.randint(1,5)) 74 await message.channel.send("終了") 75 76 77client.run(TOKEN)
あなたの回答
tips
プレビュー