class

PrivateParlorXT::AuthorizedRanks

Inherits Reference < Object

A handler for Rank and determines if a Rank has access to certain commands and message types

Constructors

new(ranks : Hash(Int32, Rank))

Creates an instance of AuthorizedRanks

Source

Instance methods

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

Source
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

Source
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.

Source
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.

Source
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.

Source
can_ranksay?(rank : Int32, invoker : Int32, invoker_permission : CommandPermissions, rank_permission : CommandPermissions | Nil = nil) : Bool

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

Source
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.

Source
max_rank

Returns the max rank value in the ranks hash

Source
rank_name(rank_value : Int32) : String | Nil

Returns the rank name associated with the given value.

Source
rank_names(limit : Int32) : Array(String)

Returns an array of all the rank names in the ranks hash, up to a rank value limit and excluding the blacklisted (-10) rank

Source
rank_names

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

Source
ranks

A hash of Int32 to Rank, where each value represents a Rank

Source
ranksay(rank : String) : String

Converts the given rank string into a string that can be used for a RanksayCommand, preceding the '-say' substring

Source
ranksay_ranks

Return an array of rank names that have a CommandPermissions::Ranksay or CommandPermissions::RanksayLower permission

Source