Class: ChatgptAssistant::VoiceConnectService
- Inherits:
-
Object
- Object
- ChatgptAssistant::VoiceConnectService
- Defined in:
- lib/chatgpt_assistant/bots/services/voice_connect_service.rb
Overview
This class is responsible to handle the discord bot
Instance Method Summary collapse
- #bot ⇒ Object
- #call ⇒ Object
-
#initialize(channel_id) ⇒ VoiceConnectService
constructor
A new instance of VoiceConnectService.
Constructor Details
#initialize(channel_id) ⇒ VoiceConnectService
Returns a new instance of VoiceConnectService.
6 7 8 9 10 |
# File 'lib/chatgpt_assistant/bots/services/voice_connect_service.rb', line 6 def initialize(channel_id) @channel_id = channel_id @config = Config.new # @config.db_connection end |
Instance Method Details
#bot ⇒ Object
12 13 14 |
# File 'lib/chatgpt_assistant/bots/services/voice_connect_service.rb', line 12 def bot @bot ||= Discordrb::Bot.new(token: @config.discord_token) end |
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chatgpt_assistant/bots/services/voice_connect_service.rb', line 16 def call bot.run :async channel = bot.channel(@channel_id) bot.voice_connect(channel) bot.join true rescue StandardError => e puts e. e.backtrace.each { |line| puts line } false end |