Class: Discordrb::Role

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

Overview

A Discord role that contains permissions and applies to certain users

Defined Under Namespace

Classes: RoleWriter

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time

Instance Attribute Details

#colourColourRGB Also known as: color

Returns the role colour.

Returns:



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

def colour
  @colour
end

#hoisttrue, false

Returns whether or not this role should be displayed separately from other users.

Returns:

  • (true, false)

    whether or not this role should be displayed separately from other users



517
518
519
# File 'lib/discordrb/data.rb', line 517

def hoist
  @hoist
end

#nameString

Returns this role's name ("new role" if it hasn't been changed).

Returns:

  • (String)

    this role's name ("new role" if it hasn't been changed)



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

def name
  @name
end

#permissionsPermissions (readonly)

Returns this role's permissions.

Returns:



511
512
513
# File 'lib/discordrb/data.rb', line 511

def permissions
  @permissions
end

Instance Method Details

#deleteObject

Delets this role. This cannot be undone without recreating the role!



599
600
601
602
# File 'lib/discordrb/data.rb', line 599

def delete
  API.delete_role(@bot.token, @server.id, @id)
  @server.delete_role(@id)
end

#inspectObject

The inspect method is overwritten to give more useful output



605
606
607
# File 'lib/discordrb/data.rb', line 605

def inspect
  "<Role name=#{@name} permissions=#{@permissions.inspect} hoist=#{@hoist} colour=#{@colour.inspect} server=#{@server.inspect}>"
end