/// <inheritdoc /> public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { if (!permissionmodule.HasPermission(command.Service, command.User, "command:create")) { SendMessage(channel, command.User, "You don't have the required permissions to create custom commands."); return; } if (command.Arguments.Length < 2) { SendMessage(channel, command.User, "Syntax: command <name> <command> <permissions>"); return; } CustomCommand customcommand = commandmodule.CreateCommand(command.Arguments[0], command.Arguments[1], command.Arguments.Length > 2 ? command.Arguments[2] : ""); commandmodule.AddCommand(customcommand); }
/// <summary> /// registers a command at the <see cref="StreamModule"/> /// </summary> /// <param name="command">command to be registered</param> public void AddCommand(CustomCommand command) { context.GetModule <StreamModule>().RegisterCommandHandler(command.ChatCommand, new CustomCommandHandler(context, command)); }
/// <summary> /// creates a new <see cref="CustomCommandHandler"/> /// </summary> /// <param name="context">access to modules (used to execute the command)</param> /// <param name="customcommand">command to be executed</param> public CustomCommandHandler(Context context, CustomCommand customcommand) { this.customcommand = customcommand; this.context = context; }