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

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

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

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

Python

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

Q&A

0回答

677閲覧

playコマンドが正しく動作しない

flog_

総合スコア0

Discord

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

Python

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

0グッド

0クリップ

投稿2021/09/11 06:48

前提・実現したいこと

自作のmusicboで一回目にボイスチャンネルに入ったときは正しく動作するのに、二回目にボイスチャンネルにはいったときは#play コマンドが正しく動作せず、エラーを吐いてしまいます

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

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Not connected to voice.

該当のソースコード

python

1@bot.command() 2async def join(ctx): 3 voicetrue = ctx.author.voice 4 if voicetrue is None: 5 return await ctx.send("ボイスチャンネルに接続されていません!") 6 await ctx.author.voice.channel.connect() 7 await ctx.send("接続しました!") 8 9@bot.command() 10async def leave(ctx): 11 voicetrue = ctx.author.voice 12 mevoicetrue = ctx.guild.me.voice 13 if voicetrue is None: 14 return await ctx.send("ボイスチャンネルに接続されていません!") 15 if mevoicetrue is None: 16 return await ctx.send("ボイスチャンネルに接続していません!") 17 await ctx.voice_client.disconnect() 18 await ctx.send("切断しました!") 19 20@bot.command() 21async def play(ctx, *, url): 22 player = music.get_player(guild_id=ctx.guild.id) 23 if not player: 24 player = music.create_player(ctx, ffmpeg_error_betterfix=True) 25 if not ctx.voice_client.is_playing(): 26 await player.queue(url, search=True) 27 song = await player.play() 28 await ctx.send(f"`{song.name}`の再生を始めました!") 29 else: 30 song = await player.queue(url, search=True) 31 await ctx.send(f"`{song.name}`をプレイリストに追加しました!") 32 33@bot.command() 34async def queue(ctx): 35 player = music.get_player(guild_id=ctx.guild.id) 36 await ctx.send(f"{','.join([song.name for song in player.current_queue()])}") 37 38@bot.command() 39async def pause(ctx): 40 player = music.get_player(guild_id=ctx.guild.id) 41 song = await player.pause() 42 await ctx.send(f'`{song.name}` の再生を止めました!') 43 44@bot.command() 45async def resume(ctx): 46 player = music.get_player(guild_id=ctx.guild.id) 47 song = await player.resume() 48 await ctx.send(f'`{song.name}` の再生を再開しました!') 49 50@bot.command() 51async def loop (ctx): 52 player = music.get_player(guild_id=ctx.guild.id) 53 song = await player.toggle_song_loop() 54 if song.is_looping: 55 return await ctx.send(f'`{song.name}`をループしました!') 56 else: 57 return await ctx.send(f'`{song.name}`のループを解除しました!') 58 59@bot.command() 60async def nowplaying(ctx): 61 player = music.get_player(guild_id=ctx.guild.id) 62 song = player.now_playing() 63 await ctx.send(song.name) 64 65@bot.command() 66async def remove(ctx, index): 67 player = music.get_player(guild_id=ctx.guild.id) 68 song = await player.remove_from_queue(int(index)) 69 await ctx.send(f'`{song.name}` をプレイリストから外しました!') 70 71@bot.command() 72async def skip(ctx): 73 voice = get(bot.voice_clients, guild=ctx.guild) 74 if voice and voice.is_playing(): 75 print('スキップしました!') 76 voice.stop() 77 await ctx.send("スキップしました!") 78 else: 79 print("次の曲がありません!") 80 await ctx.send("次の曲がありません!")

試したこと

手が付けられんませんでした。

補足情報(FW/ツールのバージョンなど)

VSCode

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

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

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

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

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

pecop

2022/09/04 10:32

英語を読みましょう。 `ClientException: Not connected to voice.`
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問