teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

質問について補足しました

2019/10/06 14:16

投稿

chanonigiri
chanonigiri

スコア5

title CHANGED
File without changes
body CHANGED
@@ -58,7 +58,72 @@
58
58
  bot.game = これをプレイ中
59
59
  end
60
60
 
61
+ ```Ruby
62
+ require 'discordrb'
63
+ bot = Discordrb::Bot.new token: 'トークン, client_id: ID
61
64
 
65
+
66
+ bot.message(content: "占い!") do |event|
67
+ p a.sample(3) #=> [1, 9, 3]
68
+ event.respond "貴方の結果は#sampleです!"
69
+ end
70
+
71
+
72
+ bot.game = これをプレイ中
73
+
74
+
75
+
76
+ bot.run
77
+
78
+ ```
79
+
80
+ ```
81
+ Microsoft Windows [Version 10.0.18362.388]
82
+ (c) 2019 Microsoft Corporation. All rights reserved.
83
+
84
+ C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
85
+
86
+ C:\Users\ユーザー名\Desktop>rubybot.rb
87
+ libsodium not available! You can continue to use discordrb as normal but voice support won't work.
88
+ Read https://github.com/meew0/discordrb/wiki/Installing-libsodium for more details.
89
+ Traceback (most recent call last):
90
+ C:/Users/ユーザー名/Desktop/rubybot.rb:563:in `<main>': undefined local variable or method `これをプレイ中' for main:Object (NameError)
91
+ ```
92
+
62
93
  ### 補足情報(FW/ツールのバージョンなど)
63
94
 
64
- 仕様ツール:ruby言語 discordrb
95
+ 仕様ツール:ruby言語 discordrb
96
+
97
+
98
+ 占いのみ実行しようとするとこうなります
99
+ ```Ruby
100
+ require 'discordrb'
101
+ bot = Discordrb::Bot.new token: 'トークン', client_id: ID
102
+
103
+
104
+
105
+ bot.message(content: "占い!") do |event|
106
+ p a.sample(3) #=> [1, 9, 3]
107
+ event.respond "貴方の結果は#sampleです!"
108
+
109
+
110
+
111
+ bot.run
112
+ ```
113
+
114
+ ```
115
+ Microsoft Windows [Version 10.0.18362.388]
116
+ (c) 2019 Microsoft Corporation. All rights reserved.
117
+
118
+ C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
119
+
120
+ C:\Users\ユーザー名\Desktop>rubybot.rb
121
+ libsodium not available! You can continue to use discordrb as normal but voice support won't work.
122
+ Read https://github.com/meew0/discordrb/wiki/Installing-libsodium for more details.
123
+ [INFO : websocket @ 2019-10-06 23:08:10.609] Discord using gateway protocol version: 6, requested: 6
124
+ [ERROR : et-1 @ 2019-10-06 23:08:18.098] Exception: #<NameError: undefined local variable or method `a' for main:Object>
125
+ [ERROR : et-1 @ 2019-10-06 23:08:18.098] C:/Users/owner/Desktop/rubybot.rb:7:in `block in <main>'
126
+ [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'
127
+ [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'
128
+
129
+ ```

2

エラーコード・ソースコードを入れました

2019/10/06 14:16

投稿

chanonigiri
chanonigiri

スコア5

title CHANGED
File without changes
body CHANGED
@@ -7,11 +7,45 @@
7
7
  ### 発生している問題・エラーメッセージ
8
8
 
9
9
  占いとプレイ中のコードの部分が構文エラーになってしまいます。
10
+ ```
11
+ Microsoft Windows [Version 10.0.18362.388]
12
+ (c) 2019 Microsoft Corporation. All rights reserved.
10
13
 
14
+ C:\Users\ユーザー名>
15
+ C:\Users\ユーザー名>cd C:\Users\ユーザー名\Desktop
16
+
17
+ C:\Users\ユーザー名\Desktop>rubybot.rb
18
+ C:/Users/ユーザー名/Desktop/rubybot.rb:12: syntax error, unexpected end, expecting end-of-input
19
+
20
+ C:\Users\ユーザー名\Desktop>
21
+
22
+
23
+ ```
24
+
11
25
  ### 該当のソースコード
12
26
 
13
27
  (前提として最低限動くトークンとIDの入力は済んでいます。簡単な受け答えは動作確認済です)
14
28
 
29
+ ```Ruby
30
+ require 'discordrb'
31
+ bot = Discordrb::Bot.new token: 'トークン', client_id: ID
32
+
33
+
34
+ bot.message(content: "占い!") do |event|
35
+ p a.sample(3) #=> [1, 9, 3]
36
+ event.respond "貴方の結果は#sampleです!"
37
+ end
38
+
39
+
40
+ bot.game = これをプレイ中
41
+ end
42
+
43
+
44
+ bot.run
45
+
46
+ ```
47
+
48
+
15
49
  ### 試したこと
16
50
 
17
51
  ::占い部分::

1

初心者マークつけました

2019/10/06 08:39

投稿

chanonigiri
chanonigiri

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- Discordbotで、占いとプレイ中の表記をしたい(ruby
1
+ Discordbotで、占いとプレイ中の表記をしたい(Ruby
body CHANGED
File without changes