Class: Discordrb::Interactions::PermissionBuilder Deprecated
- Inherits:
-
Object
- Object
- Discordrb::Interactions::PermissionBuilder
- 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
-
#allow(object) ⇒ PermissionBuilder
Allow an entity to use this command.
-
#allow_role(role_id) ⇒ PermissionBuilder
Allow a role to use this command.
-
#allow_user(user_id) ⇒ PermissionBuilder
Allow a user to use this command.
-
#deny(object) ⇒ PermissionBuilder
Deny an entity usage of this command.
-
#deny_role(role_id) ⇒ PermissionBuilder
Deny a role usage of this command.
-
#deny_user(user_id) ⇒ PermissionBuilder
Deny a user usage of this command.
-
#initialize ⇒ PermissionBuilder
constructor
A new instance of PermissionBuilder.
Constructor Details
#initialize ⇒ PermissionBuilder
Returns a new instance of PermissionBuilder.
711 712 713 |
# File 'lib/discordrb/data/interaction.rb', line 711 def initialize @permissions = [] end |
Instance Method Details
#allow(object) ⇒ PermissionBuilder
Allow an entity to use this command.
747 748 749 750 751 752 753 754 755 756 |
# File 'lib/discordrb/data/interaction.rb', line 747 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.
718 719 720 |
# File 'lib/discordrb/data/interaction.rb', line 718 def allow_role(role_id) create_entry(role_id, ROLE, true) end |
#allow_user(user_id) ⇒ PermissionBuilder
Allow a user to use this command.
732 733 734 |
# File 'lib/discordrb/data/interaction.rb', line 732 def allow_user(user_id) create_entry(user_id, USER, true) end |
#deny(object) ⇒ PermissionBuilder
Deny an entity usage of this command.
762 763 764 765 766 767 768 769 770 771 |
# File 'lib/discordrb/data/interaction.rb', line 762 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.
725 726 727 |
# File 'lib/discordrb/data/interaction.rb', line 725 def deny_role(role_id) create_entry(role_id, ROLE, false) end |
#deny_user(user_id) ⇒ PermissionBuilder
Deny a user usage of this command.
739 740 741 |
# File 'lib/discordrb/data/interaction.rb', line 739 def deny_user(user_id) create_entry(user_id, USER, false) end |