class AuthorizedRanks

Defined in:

privateparlor/rank/authorized_ranks.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ranks : Hash(Int32, Rank)) #

[View source]

Instance Method Detail

def authorized?(user_rank : Int32, permission : CommandPermissions) : Bool | Nil #

Returns true if user rank has the given command permission; user is authorized.

Returns false otherwise, or nil if the user rank does not exist in #ranks


[View source]
def authorized?(user_rank : Int32, permission : MessagePermissions) : Bool | Nil #

Returns true if user rank has the given message permission; user is authorized.

Returns false otherwise, or nil if the user rank does not exist in #ranks


[View source]
def authorized?(user_rank : Int32, *permissions : CommandPermissions) : CommandPermissions | Nil #

Returns the first symbol found from intersecting the user command permissions and the given permissions; user is authorized.

Returnsnil if the user rank does not exist in #ranks or if the rank does not have any of the given permissions.

Used for checking groups of command permissions that are similar.


[View source]
def can_demote?(rank : Int32, invoker : Int32, receiver : Int32) : Bool #

Returns true if the user to be demoted (receiver) can be demoted with the given rank.


[View source]
def can_promote?(rank : Int32, invoker : Int32, receiver : Int32, permission : CommandPermissions) : Bool #

Returns true if the user to be promoted (receiver) can be promoted with the given rank.


[View source]
def can_ranksay?(rank : Int32, invoker : Int32, invoker_permission : CommandPermissions, rank_permission : CommandPermissions | Nil) : Bool #

Returns true if the user can sign a message with the given rank.


[View source]
def find_rank(name : String, value : Int32 | Nil = nil) : Tuple(Int32, Rank) | Nil #

Finds a rank from a given rank value or iterates through the ranks hash for a rank with a given name

Returns a 2-tuple with the rank value and the rank associated with that rank, or nil if no rank exists with the given values.


[View source]
def max_rank : Int32 #

Returns the max rank value in the ranks hash


[View source]
def rank_name(rank_value : Int32) : String | Nil #

Returns the rank name associated with the given value.


[View source]
def rank_names(limit : Int32) : Array(String) #

Returns an array of all the rank names in the ranks hash, up to a rank value limit.


[View source]
def rank_names : Array(String) #

Returns an array of all the rank names in the ranks hash.


[View source]
def ranks : Hash(Int32, Rank) #

[View source]