質問編集履歴
2
コードの貼り付け場所の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
|
1
|
+
``````
|
2
|
-
|
3
|
-
https://qiita.com/Nemy/items/d895114d3ba9a9d7cb62
|
4
|
-
上記のサイトを参考にディスコードでテキスト読み上げbotを作成しています。
|
5
|
-
|
6
|
-
### 発生している問題・エラーメッセージ
|
7
|
-
|
8
|
-
.joinと打ったらボイスチャンネルに入出するはずなのですが反応しません。
|
9
|
-
|
10
2
|
import discord
|
11
3
|
from discord.ext import commands
|
12
4
|
import asyncio
|
@@ -80,8 +72,17 @@
|
|
80
72
|
|
81
73
|
|
82
74
|
client.run("botのトークン")
|
75
|
+
```
|
76
|
+
```### 前提・実現したいこと
|
83
77
|
|
78
|
+
https://qiita.com/Nemy/items/d895114d3ba9a9d7cb62
|
79
|
+
上記のサイトを参考にディスコードでテキスト読み上げbotを作成しています。
|
84
80
|
|
81
|
+
### 発生している問題・エラーメッセージ
|
82
|
+
|
83
|
+
.joinと打ったらボイスチャンネルに入出するはずなのですが反応しません。
|
84
|
+
|
85
|
+
|
85
86
|
エラー
|
86
87
|
None
|
87
88
|
#join
|
1
エラーの追加とコードの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,6 +29,7 @@
|
|
29
29
|
|
30
30
|
@client.command()
|
31
31
|
async def join(ctx):
|
32
|
+
print('#join')
|
32
33
|
print('#voicechannelを取得')
|
33
34
|
vc = ctx.author.voice.channel
|
34
35
|
print('#voicechannelに接続')
|
@@ -36,27 +37,85 @@
|
|
36
37
|
|
37
38
|
@client.command()
|
38
39
|
async def bye(ctx):
|
40
|
+
print('#bye')
|
39
41
|
print('#切断')
|
40
42
|
await ctx.voice_client.disconnect()
|
41
43
|
|
44
|
+
@client.command()
|
45
|
+
async def register(ctx, arg1, arg2):
|
46
|
+
with open('C:/open_jtalk/bin/dic.txt', mode='a') as f:
|
47
|
+
f.write('\n'+ arg1 + ',' + arg2)
|
48
|
+
print('dic.txtに書き込み:''\n'+ arg1 + ',' + arg2)
|
49
|
+
await ctx.send('`' + arg1+'` を `'+arg2+'` として登録しました')
|
50
|
+
|
42
51
|
@client.event
|
52
|
+
async def on_voice_state_update(member, before, after):
|
53
|
+
server_id_test = "サーバーID"
|
54
|
+
text_id_test = "チャンネルID"
|
55
|
+
|
56
|
+
if member.guild.id == server_id_test: # サーバーid
|
57
|
+
text_ch = client.get_channel(text_id_test) # 通知させたいTEXTチャンネルid
|
58
|
+
if before.channel is None:
|
59
|
+
msg = f'【VC参加ログ】{member.name} が {after.channel.name} に参加しました。'
|
60
|
+
await text_ch.send(msg)
|
61
|
+
|
62
|
+
@client.event
|
43
63
|
async def on_message(message):
|
64
|
+
print('---on_message_start---')
|
44
65
|
msgclient = message.guild.voice_client
|
66
|
+
print(msgclient)
|
45
67
|
if message.content.startswith('.'):
|
46
68
|
pass
|
47
69
|
|
48
70
|
else:
|
49
71
|
if message.guild.voice_client:
|
50
|
-
print(message.content)
|
72
|
+
print('#message.content:'+ message.content)
|
51
73
|
creat_WAV(message.content)
|
52
74
|
source = discord.FFmpegPCMAudio("output.wav")
|
53
75
|
message.guild.voice_client.play(source)
|
54
76
|
else:
|
55
77
|
pass
|
56
78
|
await client.process_commands(message)
|
79
|
+
print('---on_message_end---')
|
57
80
|
|
58
81
|
|
59
82
|
client.run("botのトークン")
|
83
|
+
|
84
|
+
|
85
|
+
エラー
|
86
|
+
None
|
87
|
+
#join
|
88
|
+
#voicechannelを取得
|
89
|
+
#voicechannelに接続
|
90
|
+
---on_message_end---
|
91
|
+
Ignoring exception in command join:
|
92
|
+
Traceback (most recent call last):
|
93
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, i
|
94
|
+
n wrapped
|
95
|
+
ret = await coro(*args, **kwargs)
|
96
|
+
File "C:\open_jtalk\bin\read_bot.py", line 27, in join
|
97
|
+
await vc.connect()
|
98
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1277, in connect
|
99
|
+
voice = cls(client, self)
|
100
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 199, in __
|
101
|
+
init__
|
102
|
+
raise RuntimeError("PyNaCl library needed in order to use voice")
|
103
|
+
RuntimeError: PyNaCl library needed in order to use voice
|
104
|
+
|
105
|
+
The above exception was the direct cause of the following exception:
|
106
|
+
|
107
|
+
Traceback (most recent call last):
|
108
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, i
|
109
|
+
n invoke
|
110
|
+
await ctx.command.invoke(ctx)
|
111
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863,
|
112
|
+
in invoke
|
113
|
+
await injected(*ctx.args, **ctx.kwargs)
|
114
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, i
|
115
|
+
n wrapped
|
116
|
+
raise CommandInvokeError(exc) from exc
|
117
|
+
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in orde
|
118
|
+
r to use voice
|
60
119
|
### 試したこと
|
61
120
|
|
62
121
|
権限の確認、botの再起動、再招待
|