[https://qiita.com/trompot/items/5251704272cce302af33] の記事を真似して、DiscordのBotを導入しようとしたのですが、エラーが出てしまいます。
Ruby
1# -*- encoding: utf-8 -*- 2TOKEN = '実際にトークンを取得して入れています' 3CLIENT_ID = 実際にクライアントIDを入れています 4 5# 通知用のチャンネルID 6inform_channel = '#call' 7 8# bot 9bot = Discordrb::Commands::CommandBot.new token: TOKEN,client_id: CLIENT_ID,prefix:'/' 10 11# 誰かがvoice channelに出入りしたら発火 12bot.voice_state_update do |event| 13 # 発火させたユーザー名を取得 14 user = event.user.name 15 16 # もしデータが空だと抜けていったチャンネルを取得 17 if event.channel == nil then 18 # チャンネル名を取得 19 channel_name = event.old_channel.name 20 21 # 退出したことをinform_channelに通知 22 bot.send_message(inform_channel, "@everyone #{user} が #{channel_name}を出たで~") 23 else 24 # チャンネル名を取得 25 channel_name = event.channel.name 26 27 # 入室したことをinform_channelに通知 28 bot.send_message(inform_channel, "@everyone #{user} が #{channel_name}に入ったで~") 29 end 30end 31 32# botを起動 33bot.run
エラーコード
Traceback (most recent call last):
calling_bot.rb:9:in `<main>': uninitialized constant Discordrb (NameError)
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/11 14:55
2019/01/11 15:13
2019/01/11 15:23