質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

496閲覧

DiscordBot 終了時にループのエラーが発生する

Egyma

総合スコア1

Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2021/10/10 07:13

編集2021/10/11 10:47

前提・実現したいこと

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)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問