shardlab / discordrb

Discord API for Ruby
MIT License
526 stars 95 forks source link

undefined method 'register_application_command' #100

Open Shpigford opened 2 years ago

Shpigford commented 2 years ago

Summary

Bot command returns undefined method for register_application_command and application_command

I'm running through the example for slash commands an ultimately getting errors...

require 'discordrb'

bot = Discordrb::Bot.new(token: 'TOKEN')

bot.register_application_command(:spongecase, 'Are you mocking me?', server_id: 'SERVER_ID') do |cmd|
  cmd.string('message', 'Message to spongecase')
  cmd.boolean('with_picture', 'Show the mocking sponge?')
end

The bot.register_application_command line is outputting this error:

undefined method `register_application_command' for #<Discordrb::Bot:0x000000011c04c140 @should_parse_self=false, @client_id=nil, @type=:bot, @name="", @shard_key=nil, @prevent_ready=false, @compress_mode=:large, @token="Bot TOKEN", @gateway=#<Discordrb::Gateway:0x000000011c047f00 @token="Bot TOKEN", @bot=#<Discordrb::Bot:0x000000011c04c140 ...>, @shard_key=nil, @ws_success=false, @check_heartbeat_acks=true, @compress_mode=:large, @intents=nil>, @users={}, @voice_regions={}, @servers={}, @channels={}, @pm_channels={}, @restricted_channels=[], @voices={}, @should_connect_to_voice={}, @ignored_ids=#<Set: {}>, @ignore_bots=false, @event_threads=[], @current_thread=0, @status=:online> (NoMethodError)

There's a similar output for bot.application_command


Environment

Ruby version:

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin21]

Discordrb version:

discordrb (3.4.0) discordrb-webhooks (3.3.0)

PixeLInc commented 2 years ago

Interactions are not available in 3.4.0. You need to use the main git branch in order to use the method.

You can do so by using bundler and setting your Gemfile entry to gem 'discordrb', github: 'shardlab/discordrb', branch: 'main'

If you need further assistance on this, feel free to join the Discord API server (https://discord.gg/discord-api) and head over to the #ruby_discordrb channel and we'll be glad to help there :)

DannyBen commented 2 years ago

Also got the same error and noticed indeed that current version does not have this in the code.

Any ETA on a new release that includes it?

Daniel-Worrall commented 2 years ago

At the moment, it is highly recommended to use the main branch for all current projects, (locked to a commit perhaps) since there are many bugs in 3.4.0 that occur in regular operations that will cause problems.

Our next release will be 4.0, which we are working towards but we have 1 developer doing the majority of all the planning and changes and it's highly dependent on their time, energy, and motivation for the project.

I'd advise joining the discord (https://discord.gg/discord-api) to get the most up to date information on how things are proceeding and what plans are being made

D-Forz commented 1 year ago

Recently I had this issue with my app, I find that I was executing the command with ruby app.rb. Instead, you need to use bundle exec ruby app.rb and give the permissions to your bot in Discord. Hope this can help someone, cheers.