Example #1
0
        internal bool Execte(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (this.Commands.TryGetValue(label, out ICommand command))
            {
                if (command.Permission == null || executor.HasPermission(command.Permission))
                {
                    try
                    {
                        command.OnCommand(executor, label, args);
                    }
                    catch (Exception ex)
                    {
                        CommandManager.Logger.Error(ex);

                        executor.SendMessage("Critical error while executing the command!");
                    }
                }
                else
                {
                    executor.SendMessage("You are lacking the permissions to use this command!");
                }

                return(true);
            }

            return(false);
        }