Class: Discordrb::Interactions::PermissionBuilder Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/interaction.rb

Overview

Deprecated.

This system is being replaced in the near future.

Builder for creating server application command permissions.

Constant Summary collapse

ROLE =

Role permission type

1
USER =

User permission type

2

Instance Method Summary collapse

Constructor Details

#initializePermissionBuilder

Returns a new instance of PermissionBuilder.



514
515
516
# File 'lib/discordrb/data/interaction.rb', line 514

def initialize
  @permissions = []
end

Instance Method Details

#allow(object) ⇒ PermissionBuilder

Allow an entity to use this command.

Parameters:

Returns:

Raises:

  • (ArgumentError)


550
551
552
553
554
555
556
557
558
559
# File 'lib/discordrb/data/interaction.rb', line 550

def allow(object)
  case object
  when Discordrb::User, Discordrb::Member
    create_entry(object.id, USER, true)
  when Discordrb::Role
    create_entry(object.id, ROLE, true)
  else
    raise ArgumentError, "Unable to create permission for unknown type: #{object.class}"
  end
end

#allow_role(role_id) ⇒ PermissionBuilder

Allow a role to use this command.

Parameters:

Returns:



521
522
523
# File 'lib/discordrb/data/interaction.rb', line 521

def allow_role(role_id)
  create_entry(role_id, ROLE, true)
end

#allow_user(user_id) ⇒ PermissionBuilder

Allow a user to use this command.

Parameters:

Returns:



535
536
537
# File 'lib/discordrb/data/interaction.rb', line 535

def allow_user(user_id)
  create_entry(user_id, USER, true)
end

#deny(object) ⇒ PermissionBuilder

Deny an entity usage of this command.

Parameters:

Returns:

Raises:

  • (ArgumentError)


565
566
567
568
569
570
571
572
573
574
# File 'lib/discordrb/data/interaction.rb', line 565

def deny(object)
  case object
  when Discordrb::User, Discordrb::Member
    create_entry(object.id, USER, false)
  when Discordrb::Role
    create_entry(object.id, ROLE, false)
  else
    raise ArgumentError, "Unable to create permission for unknown type: #{object.class}"
  end
end

#deny_role(role_id) ⇒ PermissionBuilder

Deny a role usage of this command.

Parameters:

Returns:



528
529
530
# File 'lib/discordrb/data/interaction.rb', line 528

def deny_role(role_id)
  create_entry(role_id, ROLE, false)
end

#deny_user(user_id) ⇒ PermissionBuilder

Deny a user usage of this command.

Parameters:

Returns:



542
543
544
# File 'lib/discordrb/data/interaction.rb', line 542

def deny_user(user_id)
  create_entry(user_id, USER, false)
end