mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Added Role Commands
This commit is contained in:
45
modules/commands/roles.lua
Normal file
45
modules/commands/roles.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Roles = require 'expcore.roles'
|
||||
local Colours = require 'resources.color_presets'
|
||||
|
||||
Commands.new_command('assign-role','Assigns a role to a player')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('role',false,'role')
|
||||
:set_flag('admin-only',true)
|
||||
:add_alias('rpromote','assign','role','add-role')
|
||||
:register(function(player,action_player,role,raw)
|
||||
local player_highest = Roles.get_player_highest(player)
|
||||
if player_highest.index < role.index then
|
||||
Roles.assign_player(action_player,role,player.name)
|
||||
else
|
||||
return Commands.error{'exp-commands.roles-higher-role'}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('unassign-role','Unassigns a role from a player')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('role',false,'role')
|
||||
:set_flag('admin-only',true)
|
||||
:add_alias('rdemote','unassign','remove-role')
|
||||
:register(function(player,action_player,role,raw)
|
||||
local player_highest = Roles.get_player_highest(player)
|
||||
if player_highest.index < role.index then
|
||||
Roles.unassign_player(action_player,role,player.name)
|
||||
else
|
||||
return Commands.error{'exp-commands.roles-higher-role'}
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.new_command('list-roles','Lists all roles in they correct order')
|
||||
:add_alias('lroles','roles')
|
||||
:register(function(player,raw)
|
||||
local roles = Roles.config.order
|
||||
local message = {'exp-commands.roles-list'}
|
||||
for _,role_name in pairs(roles) do
|
||||
local role = Roles.get_role_by_name(role_name)
|
||||
local colour = role.custom_color or Colours.white
|
||||
colour = string.format('%d,%d,%d',colour.r,colour.g,colour.b)
|
||||
message = {'exp-commands.roles-list-element',message,colour,role_name}
|
||||
end
|
||||
return Commands.success(message)
|
||||
end)
|
||||
Reference in New Issue
Block a user