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

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

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

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

Python

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

Q&A

0回答

918閲覧

discord botが反応しない

fuyune

総合スコア2

Discord

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

Python

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

0グッド

1クリップ

投稿2021/01/17 07:42

前提・実現したいこと

glitchを使ってテキストを読み上げるdiscord botを作りたいと思っています
現在botはオンラインなのですが、反応が返ってきません
何が問題なのでしょうか、とりあえずVCに入るようにしたいです
コードは色々なところから借りています

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

glitchのログにエラーは多分出てないです 以下ログです

Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: discord.py[voice] in ./.local/lib/python3.7/site-packages (1.6.0) Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in ./.local/lib/python3.7/site-packages (from discord.py[voice]) (3.7.3) Requirement already satisfied: PyNaCl<1.5,>=1.3.0 in ./.local/lib/python3.7/site-packages (from discord.py[voice]) (1.4.0) Requirement already satisfied: async-timeout<4.0,>=3.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.0.1) Requirement already satisfied: multidict<7.0,>=4.5 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (5.1.0) Requirement already satisfied: yarl<2.0,>=1.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (1.6.3) Requirement already satisfied: attrs>=17.3.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (20.3.0) Requirement already satisfied: chardet<4.0,>=2.0 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.0.4) Requirement already satisfied: typing-extensions>=3.6.5 in ./.local/lib/python3.7/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.7.4.3) Requirement already satisfied: cffi>=1.4.1 in ./.local/lib/python3.7/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.14.4) Requirement already satisfied: six in ./.local/lib/python3.7/site-packages (from PyNaCl<1.5,>=1.3.0->discord.py[voice]) (1.15.0) Requirement already satisfied: pycparser in ./.local/lib/python3.7/site-packages (from cffi>=1.4.1->PyNaCl<1.5,>=1.3.0->discord.py[voice]) (2.20) Requirement already satisfied: idna>=2.0 in ./.local/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py[voice]) (3.1)

該当のソースコード

python

1import asyncio 2import re 3from aquestalk import * 4import discord 5from discord.ext import commands 6 7bot = commands.Bot(command_prefix='.') 8 9@bot.event 10async def on_ready(): 11 print("ready") 12 13@bot.command() 14async def s(ctx): 15 #voicechannelを取得 16 vc = ctx.author.voice.channel 17 #voicechannelに接続 18 await vc.connect() 19 20@bot.command() 21async def e(ctx): 22 await vc.disconnect() 23 24@bot.event 25async def on_message(message): 26 # bot自身のメッセージは何もしない 27 if message.author.bot: 28 return 29 30 # ユーザーidが含まれる場合ユーザー名に変換する 31 pattern = r"<@!(?P<user_id>\d+)>" 32 m = re.match(pattern, message.content) 33 if m: 34 user_name = bot.get_user(int(m.group("user_id"))).name 35 message.content = re.sub(pattern, user_name, message.content) 36 37 # URLは省略する 38 pattern = r"https?://[\w/:%#$&?()~.=+\-]+" 39 m = re.match(pattern, message.content) 40 if m: 41 message.content = re.sub(pattern, 'URL省略', message.content) 42 43 # 喋っている途中は待つ 44 while voice_client.is_playing(): 45 await asyncio.sleep(0.5) 46 47 # wavファイルに変換 48 aq = aquestalk.load('f1') 49 wav = aq.synthe("message.content") 50 type(wav) 51 52 # wavファイルをボイチャに流す 53 source = discord.FFmpegPCMAudio(wav) 54 voice_client.play(source) 55 56 await bot.process_commands(message) 57 58bot.run()

json

1{ 2 "install": "pip3 install -U discord.py[voice]", 3 "start": "python3 discordbot.py" 4}

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問