class Discorb::CommandInteraction::SlashCommand
Represents a slash command interaction.
Private Instance Methods
_set_data(data)
click to toggle source
Calls superclass method
Discorb::CommandInteraction#_set_data
# File lib/discorb/interaction.rb, line 260 def _set_data(data) super Sync do name = data[:name] options = nil if (option = data[:options]&.first) case option[:type] when 1 name += " #{option[:name]}" options = option[:options] when 2 name += " #{option[:name]}" if (option_sub = option[:options]&.first) if option_sub[:type] == 1 name += " #{option_sub[:name]}" options = option_sub[:options] else options = option[:options] end end else options = data[:options] end end options ||= [] options.map! do |option| case option[:type] when 3, 4, 5, 10 option[:value] when 6 guild.members[option[:value]] || guild.fetch_member(option[:value]).wait when 7 guild.channels[option[:value]] || guild.fetch_channels.wait.find { |channel| channel.id == option[:value] } when 8 guild.roles[option[:value]] || guild.fetch_roles.wait.find { |role| role.id == option[:value] } when 9 guild.members[option[:value]] || guild.roles[option[:value]] || guild.fetch_member(option[:value]).wait || guild.fetch_roles.wait.find { |role| role.id == option[:value] } end end unless (command = @client.bottom_commands.find { |c| c.to_s == name && c.type_raw == 1 }) @client.log.warn "Unknown command name #{name}, ignoreing" next end command.block.call(self, *options) end end