質問編集履歴
2
コードの貼り付け場所の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,154 @@
|
|
1
|
+
``````
|
2
|
+
|
3
|
+
import discord
|
4
|
+
|
5
|
+
from discord.ext import commands
|
6
|
+
|
7
|
+
import asyncio
|
8
|
+
|
9
|
+
import os
|
10
|
+
|
11
|
+
import subprocess
|
12
|
+
|
13
|
+
import ffmpeg
|
14
|
+
|
15
|
+
from voice_generator import creat_WAV
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
client = commands.Bot(command_prefix='.')
|
20
|
+
|
21
|
+
voice_client = None
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
@client.event
|
28
|
+
|
29
|
+
async def on_ready():
|
30
|
+
|
31
|
+
print('Logged in as')
|
32
|
+
|
33
|
+
print(client.user.name)
|
34
|
+
|
35
|
+
print(client.user.id)
|
36
|
+
|
37
|
+
print('------')
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
@client.command()
|
44
|
+
|
45
|
+
async def join(ctx):
|
46
|
+
|
47
|
+
print('#join')
|
48
|
+
|
49
|
+
print('#voicechannelを取得')
|
50
|
+
|
51
|
+
vc = ctx.author.voice.channel
|
52
|
+
|
53
|
+
print('#voicechannelに接続')
|
54
|
+
|
55
|
+
await vc.connect()
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
@client.command()
|
60
|
+
|
61
|
+
async def bye(ctx):
|
62
|
+
|
63
|
+
print('#bye')
|
64
|
+
|
65
|
+
print('#切断')
|
66
|
+
|
67
|
+
await ctx.voice_client.disconnect()
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
@client.command()
|
72
|
+
|
73
|
+
async def register(ctx, arg1, arg2):
|
74
|
+
|
75
|
+
with open('C:/open_jtalk/bin/dic.txt', mode='a') as f:
|
76
|
+
|
77
|
+
f.write('\n'+ arg1 + ',' + arg2)
|
78
|
+
|
79
|
+
print('dic.txtに書き込み:''\n'+ arg1 + ',' + arg2)
|
80
|
+
|
81
|
+
await ctx.send('`' + arg1+'` を `'+arg2+'` として登録しました')
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
@client.event
|
86
|
+
|
87
|
+
async def on_voice_state_update(member, before, after):
|
88
|
+
|
89
|
+
server_id_test = "サーバーID"
|
90
|
+
|
91
|
+
text_id_test = "チャンネルID"
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if member.guild.id == server_id_test: # サーバーid
|
96
|
+
|
97
|
+
text_ch = client.get_channel(text_id_test) # 通知させたいTEXTチャンネルid
|
98
|
+
|
99
|
+
if before.channel is None:
|
100
|
+
|
101
|
+
msg = f'【VC参加ログ】{member.name} が {after.channel.name} に参加しました。'
|
102
|
+
|
103
|
+
await text_ch.send(msg)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
@client.event
|
108
|
+
|
109
|
+
async def on_message(message):
|
110
|
+
|
111
|
+
print('---on_message_start---')
|
112
|
+
|
113
|
+
msgclient = message.guild.voice_client
|
114
|
+
|
115
|
+
print(msgclient)
|
116
|
+
|
117
|
+
if message.content.startswith('.'):
|
118
|
+
|
119
|
+
pass
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
else:
|
124
|
+
|
125
|
+
if message.guild.voice_client:
|
126
|
+
|
127
|
+
print('#message.content:'+ message.content)
|
128
|
+
|
129
|
+
creat_WAV(message.content)
|
130
|
+
|
131
|
+
source = discord.FFmpegPCMAudio("output.wav")
|
132
|
+
|
133
|
+
message.guild.voice_client.play(source)
|
134
|
+
|
135
|
+
else:
|
136
|
+
|
137
|
+
pass
|
138
|
+
|
139
|
+
await client.process_commands(message)
|
140
|
+
|
141
|
+
print('---on_message_end---')
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
client.run("botのトークン")
|
148
|
+
|
149
|
+
```
|
150
|
+
|
1
|
-
### 前提・実現したいこと
|
151
|
+
```### 前提・実現したいこと
|
2
152
|
|
3
153
|
|
4
154
|
|
@@ -16,218 +166,70 @@
|
|
16
166
|
|
17
167
|
|
18
168
|
|
169
|
+
|
170
|
+
|
19
|
-
|
171
|
+
エラー
|
20
|
-
|
21
|
-
|
172
|
+
|
22
|
-
|
23
|
-
|
173
|
+
None
|
24
|
-
|
174
|
+
|
25
|
-
i
|
175
|
+
#join
|
26
|
-
|
27
|
-
|
176
|
+
|
28
|
-
|
29
|
-
import ffmpeg
|
30
|
-
|
31
|
-
from voice_generator import creat_WAV
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
client = commands.Bot(command_prefix='.')
|
36
|
-
|
37
|
-
voice
|
177
|
+
#voicechannelを取得
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
178
|
+
|
44
|
-
|
45
|
-
async def on_ready():
|
46
|
-
|
47
|
-
print('Logged in as')
|
48
|
-
|
49
|
-
print(client.user.name)
|
50
|
-
|
51
|
-
print(client.user.id)
|
52
|
-
|
53
|
-
print('------')
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@client.command()
|
60
|
-
|
61
|
-
async def join(ctx):
|
62
|
-
|
63
|
-
print('#join')
|
64
|
-
|
65
|
-
print('#voicechannelを取得')
|
66
|
-
|
67
|
-
vc = ctx.author.voice.channel
|
68
|
-
|
69
|
-
|
179
|
+
#voicechannelに接続
|
180
|
+
|
181
|
+
---on_message_end---
|
182
|
+
|
183
|
+
Ignoring exception in command join:
|
184
|
+
|
185
|
+
Traceback (most recent call last):
|
186
|
+
|
187
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, i
|
188
|
+
|
189
|
+
n wrapped
|
190
|
+
|
191
|
+
ret = await coro(*args, **kwargs)
|
192
|
+
|
193
|
+
File "C:\open_jtalk\bin\read_bot.py", line 27, in join
|
70
194
|
|
71
195
|
await vc.connect()
|
72
196
|
|
73
|
-
|
74
|
-
|
75
|
-
@client.command()
|
76
|
-
|
77
|
-
async def bye(ctx):
|
78
|
-
|
79
|
-
print('#bye')
|
80
|
-
|
81
|
-
print('#切断')
|
82
|
-
|
83
|
-
await ctx.voice_client.disconnect()
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
@client.command()
|
88
|
-
|
89
|
-
async def register(ctx, arg1, arg2):
|
90
|
-
|
91
|
-
|
197
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1277, in connect
|
92
|
-
|
93
|
-
|
198
|
+
|
94
|
-
|
95
|
-
print('dic.txtに書き込み:''\n'+ arg1 + ',' + arg2)
|
96
|
-
|
97
|
-
await ctx.send('`' + arg1+'` を `'+arg2+'` として登録しました')
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
@client.event
|
102
|
-
|
103
|
-
async def on_voice_state_update(member, before, after):
|
104
|
-
|
105
|
-
server_id_test = "サーバーID"
|
106
|
-
|
107
|
-
text_id_test = "チャンネルID"
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
if member.guild.id == server_id_test: # サーバーid
|
112
|
-
|
113
|
-
text_ch = client.get_channel(text_id_test) # 通知させたいTEXTチャンネルid
|
114
|
-
|
115
|
-
if before.channel is None:
|
116
|
-
|
117
|
-
msg = f'【VC参加ログ】{member.name} が {after.channel.name} に参加しました。'
|
118
|
-
|
119
|
-
await text_ch.send(msg)
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
@client.event
|
124
|
-
|
125
|
-
async def on_message(message):
|
126
|
-
|
127
|
-
print('---on_message_start---')
|
128
|
-
|
129
|
-
msgclient = message.guild.voice_client
|
130
|
-
|
131
|
-
|
199
|
+
voice = cls(client, self)
|
132
|
-
|
200
|
+
|
133
|
-
|
201
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 199, in __
|
134
|
-
|
135
|
-
|
202
|
+
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
203
|
+
init__
|
140
|
-
|
141
|
-
|
204
|
+
|
142
|
-
|
143
|
-
print('#message.content:'+ message.content)
|
144
|
-
|
145
|
-
creat_WAV(message.content)
|
146
|
-
|
147
|
-
|
205
|
+
raise RuntimeError("PyNaCl library needed in order to use voice")
|
148
|
-
|
206
|
+
|
149
|
-
|
207
|
+
RuntimeError: PyNaCl library needed in order to use voice
|
150
|
-
|
151
|
-
|
208
|
+
|
152
|
-
|
153
|
-
|
209
|
+
|
154
|
-
|
155
|
-
|
210
|
+
|
156
|
-
|
157
|
-
print('---on_message_end---')
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
client.run("botのトークン")
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
エラー
|
170
|
-
|
171
|
-
None
|
172
|
-
|
173
|
-
#join
|
174
|
-
|
175
|
-
#voicechannelを取得
|
176
|
-
|
177
|
-
#voicechannelに接続
|
178
|
-
|
179
|
-
---on_message_end---
|
180
|
-
|
181
|
-
|
211
|
+
The above exception was the direct cause of the following exception:
|
212
|
+
|
213
|
+
|
182
214
|
|
183
215
|
Traceback (most recent call last):
|
184
216
|
|
217
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, i
|
218
|
+
|
219
|
+
n invoke
|
220
|
+
|
221
|
+
await ctx.command.invoke(ctx)
|
222
|
+
|
223
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863,
|
224
|
+
|
225
|
+
in invoke
|
226
|
+
|
227
|
+
await injected(*ctx.args, **ctx.kwargs)
|
228
|
+
|
185
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line
|
229
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, i
|
186
230
|
|
187
231
|
n wrapped
|
188
232
|
|
189
|
-
ret = await coro(*args, **kwargs)
|
190
|
-
|
191
|
-
File "C:\open_jtalk\bin\read_bot.py", line 27, in join
|
192
|
-
|
193
|
-
await vc.connect()
|
194
|
-
|
195
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1277, in connect
|
196
|
-
|
197
|
-
voice = cls(client, self)
|
198
|
-
|
199
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 199, in __
|
200
|
-
|
201
|
-
init__
|
202
|
-
|
203
|
-
raise RuntimeError("PyNaCl library needed in order to use voice")
|
204
|
-
|
205
|
-
RuntimeError: PyNaCl library needed in order to use voice
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
The above exception was the direct cause of the following exception:
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
Traceback (most recent call last):
|
214
|
-
|
215
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, i
|
216
|
-
|
217
|
-
n invoke
|
218
|
-
|
219
|
-
await ctx.command.invoke(ctx)
|
220
|
-
|
221
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863,
|
222
|
-
|
223
|
-
in invoke
|
224
|
-
|
225
|
-
await injected(*ctx.args, **ctx.kwargs)
|
226
|
-
|
227
|
-
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, i
|
228
|
-
|
229
|
-
n wrapped
|
230
|
-
|
231
233
|
raise CommandInvokeError(exc) from exc
|
232
234
|
|
233
235
|
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in orde
|
1
エラーの追加とコードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,6 +60,8 @@
|
|
60
60
|
|
61
61
|
async def join(ctx):
|
62
62
|
|
63
|
+
print('#join')
|
64
|
+
|
63
65
|
print('#voicechannelを取得')
|
64
66
|
|
65
67
|
vc = ctx.author.voice.channel
|
@@ -74,18 +76,60 @@
|
|
74
76
|
|
75
77
|
async def bye(ctx):
|
76
78
|
|
79
|
+
print('#bye')
|
80
|
+
|
77
81
|
print('#切断')
|
78
82
|
|
79
83
|
await ctx.voice_client.disconnect()
|
80
84
|
|
81
85
|
|
82
86
|
|
87
|
+
@client.command()
|
88
|
+
|
89
|
+
async def register(ctx, arg1, arg2):
|
90
|
+
|
91
|
+
with open('C:/open_jtalk/bin/dic.txt', mode='a') as f:
|
92
|
+
|
93
|
+
f.write('\n'+ arg1 + ',' + arg2)
|
94
|
+
|
95
|
+
print('dic.txtに書き込み:''\n'+ arg1 + ',' + arg2)
|
96
|
+
|
97
|
+
await ctx.send('`' + arg1+'` を `'+arg2+'` として登録しました')
|
98
|
+
|
99
|
+
|
100
|
+
|
83
101
|
@client.event
|
84
102
|
|
103
|
+
async def on_voice_state_update(member, before, after):
|
104
|
+
|
105
|
+
server_id_test = "サーバーID"
|
106
|
+
|
107
|
+
text_id_test = "チャンネルID"
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
if member.guild.id == server_id_test: # サーバーid
|
112
|
+
|
113
|
+
text_ch = client.get_channel(text_id_test) # 通知させたいTEXTチャンネルid
|
114
|
+
|
115
|
+
if before.channel is None:
|
116
|
+
|
117
|
+
msg = f'【VC参加ログ】{member.name} が {after.channel.name} に参加しました。'
|
118
|
+
|
119
|
+
await text_ch.send(msg)
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
@client.event
|
124
|
+
|
85
125
|
async def on_message(message):
|
86
126
|
|
127
|
+
print('---on_message_start---')
|
128
|
+
|
87
129
|
msgclient = message.guild.voice_client
|
88
130
|
|
131
|
+
print(msgclient)
|
132
|
+
|
89
133
|
if message.content.startswith('.'):
|
90
134
|
|
91
135
|
pass
|
@@ -96,7 +140,7 @@
|
|
96
140
|
|
97
141
|
if message.guild.voice_client:
|
98
142
|
|
99
|
-
print(message.content)
|
143
|
+
print('#message.content:'+ message.content)
|
100
144
|
|
101
145
|
creat_WAV(message.content)
|
102
146
|
|
@@ -110,12 +154,86 @@
|
|
110
154
|
|
111
155
|
await client.process_commands(message)
|
112
156
|
|
157
|
+
print('---on_message_end---')
|
158
|
+
|
113
159
|
|
114
160
|
|
115
161
|
|
116
162
|
|
117
163
|
client.run("botのトークン")
|
118
164
|
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
エラー
|
170
|
+
|
171
|
+
None
|
172
|
+
|
173
|
+
#join
|
174
|
+
|
175
|
+
#voicechannelを取得
|
176
|
+
|
177
|
+
#voicechannelに接続
|
178
|
+
|
179
|
+
---on_message_end---
|
180
|
+
|
181
|
+
Ignoring exception in command join:
|
182
|
+
|
183
|
+
Traceback (most recent call last):
|
184
|
+
|
185
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, i
|
186
|
+
|
187
|
+
n wrapped
|
188
|
+
|
189
|
+
ret = await coro(*args, **kwargs)
|
190
|
+
|
191
|
+
File "C:\open_jtalk\bin\read_bot.py", line 27, in join
|
192
|
+
|
193
|
+
await vc.connect()
|
194
|
+
|
195
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1277, in connect
|
196
|
+
|
197
|
+
voice = cls(client, self)
|
198
|
+
|
199
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 199, in __
|
200
|
+
|
201
|
+
init__
|
202
|
+
|
203
|
+
raise RuntimeError("PyNaCl library needed in order to use voice")
|
204
|
+
|
205
|
+
RuntimeError: PyNaCl library needed in order to use voice
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
The above exception was the direct cause of the following exception:
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
Traceback (most recent call last):
|
214
|
+
|
215
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, i
|
216
|
+
|
217
|
+
n invoke
|
218
|
+
|
219
|
+
await ctx.command.invoke(ctx)
|
220
|
+
|
221
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863,
|
222
|
+
|
223
|
+
in invoke
|
224
|
+
|
225
|
+
await injected(*ctx.args, **ctx.kwargs)
|
226
|
+
|
227
|
+
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, i
|
228
|
+
|
229
|
+
n wrapped
|
230
|
+
|
231
|
+
raise CommandInvokeError(exc) from exc
|
232
|
+
|
233
|
+
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in orde
|
234
|
+
|
235
|
+
r to use voice
|
236
|
+
|
119
237
|
### 試したこと
|
120
238
|
|
121
239
|
|