質問編集履歴
3
質問について補足しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,6 +118,68 @@
|
|
118
118
|
|
119
119
|
|
120
120
|
|
121
|
+
```Ruby
|
122
|
+
|
123
|
+
require 'discordrb'
|
124
|
+
|
125
|
+
bot = Discordrb::Bot.new token: 'トークン, client_id: ID
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
bot.message(content: "占い!") do |event|
|
132
|
+
|
133
|
+
p a.sample(3) #=> [1, 9, 3]
|
134
|
+
|
135
|
+
event.respond "貴方の結果は#sampleです!"
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
bot.game = これをプレイ中
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
bot.run
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
Microsoft Windows [Version 10.0.18362.388]
|
162
|
+
|
163
|
+
(c) 2019 Microsoft Corporation. All rights reserved.
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
C:\Users\ユーザー名\Desktop>rubybot.rb
|
172
|
+
|
173
|
+
libsodium not available! You can continue to use discordrb as normal but voice support won't work.
|
174
|
+
|
175
|
+
Read https://github.com/meew0/discordrb/wiki/Installing-libsodium for more details.
|
176
|
+
|
177
|
+
Traceback (most recent call last):
|
178
|
+
|
179
|
+
C:/Users/ユーザー名/Desktop/rubybot.rb:563:in `<main>': undefined local variable or method `これをプレイ中' for main:Object (NameError)
|
180
|
+
|
181
|
+
```
|
182
|
+
|
121
183
|
|
122
184
|
|
123
185
|
### 補足情報(FW/ツールのバージョンなど)
|
@@ -125,3 +187,71 @@
|
|
125
187
|
|
126
188
|
|
127
189
|
仕様ツール:ruby言語 discordrb
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
占いのみ実行しようとするとこうなります
|
196
|
+
|
197
|
+
```Ruby
|
198
|
+
|
199
|
+
require 'discordrb'
|
200
|
+
|
201
|
+
bot = Discordrb::Bot.new token: 'トークン', client_id: ID
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
bot.message(content: "占い!") do |event|
|
210
|
+
|
211
|
+
p a.sample(3) #=> [1, 9, 3]
|
212
|
+
|
213
|
+
event.respond "貴方の結果は#sampleです!"
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
bot.run
|
222
|
+
|
223
|
+
```
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
```
|
228
|
+
|
229
|
+
Microsoft Windows [Version 10.0.18362.388]
|
230
|
+
|
231
|
+
(c) 2019 Microsoft Corporation. All rights reserved.
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
C:\Users\ユーザー名\Desktop>rubybot.rb
|
240
|
+
|
241
|
+
libsodium not available! You can continue to use discordrb as normal but voice support won't work.
|
242
|
+
|
243
|
+
Read https://github.com/meew0/discordrb/wiki/Installing-libsodium for more details.
|
244
|
+
|
245
|
+
[INFO : websocket @ 2019-10-06 23:08:10.609] Discord using gateway protocol version: 6, requested: 6
|
246
|
+
|
247
|
+
[ERROR : et-1 @ 2019-10-06 23:08:18.098] Exception: #<NameError: undefined local variable or method `a' for main:Object>
|
248
|
+
|
249
|
+
[ERROR : et-1 @ 2019-10-06 23:08:18.098] C:/Users/owner/Desktop/rubybot.rb:7:in `block in <main>'
|
250
|
+
|
251
|
+
[ERROR : et-1 @ 2019-10-06 23:08:18.098] D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/discordrb-3.3.0/lib/discordrb/events/generic.rb:98:in `call'
|
252
|
+
|
253
|
+
[ERROR : et-1 @ 2019-10-06 23:08:18.098] D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/discordrb-3.3.0/lib/discordrb/bot.rb:1316:in `block in call_event'
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
```
|
2
エラーコード・ソースコードを入れました
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,34 @@
|
|
16
16
|
|
17
17
|
占いとプレイ中のコードの部分が構文エラーになってしまいます。
|
18
18
|
|
19
|
+
```
|
20
|
+
|
21
|
+
Microsoft Windows [Version 10.0.18362.388]
|
22
|
+
|
23
|
+
(c) 2019 Microsoft Corporation. All rights reserved.
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
C:\Users\ユーザー名>
|
28
|
+
|
29
|
+
C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
C:\Users\ユーザー名\Desktop>rubybot.rb
|
34
|
+
|
35
|
+
C:/Users/ユーザー名/Desktop/rubybot.rb:12: syntax error, unexpected end, expecting end-of-input
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
C:\Users\ユーザー名\Desktop>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```
|
46
|
+
|
19
47
|
|
20
48
|
|
21
49
|
### 該当のソースコード
|
@@ -23,6 +51,46 @@
|
|
23
51
|
|
24
52
|
|
25
53
|
(前提として最低限動くトークンとIDの入力は済んでいます。簡単な受け答えは動作確認済です)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```Ruby
|
58
|
+
|
59
|
+
require 'discordrb'
|
60
|
+
|
61
|
+
bot = Discordrb::Bot.new token: 'トークン', client_id: ID
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
bot.message(content: "占い!") do |event|
|
68
|
+
|
69
|
+
p a.sample(3) #=> [1, 9, 3]
|
70
|
+
|
71
|
+
event.respond "貴方の結果は#sampleです!"
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
bot.game = これをプレイ中
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
bot.run
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
```
|
92
|
+
|
93
|
+
|
26
94
|
|
27
95
|
|
28
96
|
|
1
初心者マークつけました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Discordbotで、占いとプレイ中の表記をしたい(
|
1
|
+
Discordbotで、占いとプレイ中の表記をしたい(Ruby)
|
test
CHANGED
File without changes
|